我有 2 个以警报管理器开头的通知。运行完美,但我有一个问题:当第一个通知处于活动状态时(在通知栏中),如果我不点击它,并且第二个通知开始,我会看到新通知,但如果我点击新活动显示第一个通知。
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = not1[x];
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
CharSequence contentTitle = "title";
CharSequence contentText = not1[x];
Intent notificationIntent = new Intent("org.gortcloud.perledisaggezza", null, context, Notify.class);
notificationIntent.putExtra("notify", not1[x]);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);