【发布时间】:2014-08-28 23:16:05
【问题描述】:
我在通知意图方面遇到了麻烦。我有一个创建通知的服务(服务检查消息并创建通知)。应用程序有一个操作栏,用户可以通过滑动菜单在活动之间导航。
http://i.stack.imgur.com/YJXe6.png
当用户点击通知时,它会在当前活动上打开一个新活动。(就像一个独立的新实例)。我想在与用户手动导航相同的实例中打开它们(就像在 B 活动上单击 A ie)
我当前的活动启动模式是标准的(虽然我尝试了 singleTop 和 singleTask 和 flags)
当前通知代码:
Intent i = null;
i = new Intent(this, MessagesListActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,i, 0);
Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(msg);
notificationBuilder.setSmallIcon(R.drawable.speech_bubble_orange);
notificationBuilder.setContentIntent(contentIntent);
notificationBuilder.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = notificationBuilder.build();
notificationManager.notify(Constants.UNREADMESSAGESNOTIFICATIONID,notification);
感谢您的帮助。
【问题讨论】:
标签: java android android-activity notifications