【发布时间】:2012-04-03 18:06:35
【问题描述】:
我正在向通知栏发布不同的通知。
所有人都有不同的 id,但意图是针对相同的活动。
当我点击第一个通知时,活动开始并点击结束。
当我的活动完成后,栏中所有剩余的通知都会消失。
我希望他们留在通知栏上。
如何做到这一点。
这是代码。
mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
int id = 10;
notificationIntent = new Intent(context, MyAct.class); // creating intent.
notificationIntent.putExtra("data", data);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// defining actions while notification.
contentIntent = PendingIntent.getActivity(context, id,notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification = new Notification(R.drawable.icon, message,
System.currentTimeMillis());
notification.setLatestEventInfo(context, "Hello", message,
contentIntent);
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.defaults |= Notification.DEFAULT_SOUND;
mNotificationManager.notify(id, notification);
id++;
提前谢谢....!
【问题讨论】:
标签: android android-activity notifications