当用户在显示活动A时点击状态栏中的通知时,我不想启动活动,但是当A被销毁或不可见时,当用户点击通知时,活动已经正常启动。
我该怎么办?谢谢!
更新,这是我显示通知的代码:
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.putExtra(GCMReceiver.EXTRA_NOTIFICATION_MESSAGE,
notiMessage);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this.context);
mBuilder.setContentText(message);
mBuilder.setContentTitle(title);
mBuilder.setAutoCancel(true).setSmallIcon(R.drawable.ic_notification)
.setContentIntent(pendingIntent);
mNotificationManager.notify(KEY_PUSH_NOTIFICATION, mBuilder.build());
答案 0 :(得分:0)
当用户点击通知时,您可以初始化pendingIntent,如下所示:
PendingIntent contentIntent =
PendingIntent.getActivity(context, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);