私は通知を上げました。私が欲しいのは、ユーザーが通知をクリックすると、新しいインスタンスを作成せずにアクティビティが前面に表示されることです。このために、フラグ REORDER_TO_FRONT を追加しましたが、通知をクリックすると、onNewIntent の代わりに oncreate が呼び出されます。
これは私のコードです -
int icon = R.drawable.android;
long when = System.currentTimeMillis();
CharSequence text = "new message";
CharSequence contentTitle = stanza.getFrom(); // message title
CharSequence contentText = stanza.getBody(); // message text
Intent notificationIntent = new Intent(context, ChatBox.class);
notificationIntent.putExtra("buddyid",stanza.getFrom());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);
// the next two lines initialize the Notification, using the configurations above
Notification notification = new Notification(icon, text, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1,notification);