AndroidアプリのGCMで通知を作成していますが、通知を正常に作成できますが、ドラッグダウンバーから通知を開こうとすると、アプリが開きません。LogCatをチェックインすると、次のようなトレースバックが表示されます。
08-21 22:31:31.250: ERROR/ActivityManager(275): startLaunchActivity get appname failed
java.lang.NullPointerException
at com.android.server.am.ActivityStack.startLaunchActivity(ActivityStack.java:4654)
at com.android.server.am.ActivityStack.startActivityMayWait(ActivityStack.java:3196)
at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:2628)
at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:231)
at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:182)
at android.content.IIntentSender$Stub.onTransact(IIntentSender.java:64)
at android.os.Binder.execTransact(Binder.java:338)
at dalvik.system.NativeStart.run(Native Method)
08-21 22:31:31.250: INFO/ActivityManager(275): START intent from pid -1
これを引き起こしているアイデアと、それを解決する方法はありますか?必要に応じてコードを提供できます。
ありがとう!
通知作成コード:
@Override
protected void onMessage(Context context, Intent intent) {
String msg = intent.getStringExtra(Constants.FIELD_MESSAGE);
Log.e("We got a message from the server",msg);
NotificationManager manager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = prepareNotification(context, msg);
manager.notify(R.id.notification_id, notification);
Log.e("Sent notification event","");
}
private Notification prepareNotification(Context context, String msg) {
long when = System.currentTimeMillis();
Notification notification = new Notification(R.drawable.ic_stat_cloud, msg,
when);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(context, MessageActivity.class);
// Set a unique data uri for each notification to make sure the activity
// gets updated
intent.setData(Uri.parse(msg));
intent.putExtra(Constants.FIELD_MESSAGE, msg);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
0);
String title = context.getString(R.string.app_name);
notification.setLatestEventInfo(context, title, msg, pendingIntent);
return notification;
}
通知処理コード:
public class MessageActivity extends Activity {
private TextView mMessageView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("opening message notification","");
setContentView(R.layout.activity_message);
Log.e("displaying message","");
mMessageView = (TextView) findViewById(R.id.message);
Log.e("put message","");
}
@Override
public void onResume() {
super.onResume();
String msg = getIntent().getStringExtra(Constants.FIELD_MESSAGE);
mMessageView.setText(msg);
}
}