假设我的应用程序使用文本“hello”发布状态栏通知。
“hello”通知在通知区域显示正常
现在,如果我的应用程序在第一个“你好”仍在通知区域时再次发布“hello”,则通知区域仍然包含一个“hello”通知,
那也没关系。
但现在,如果从通知区域取消(删除)第一个“你好”通知,然后
发布第二个“你好”通知,我希望通知区域显示
再次发出(第二个)“你好”通知,但它没有显示任何“你好”通知。
为什么会这样,我该如何解决这个问题?
这就是我所做的: 在发布通知之前我总是: intent.setAction(“”+ new Date()。getTime()); 我创建了一个内容意图,如:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, flag);
我为'flag'尝试了以下所有值,但没有一个能解决问题:
1)PendingIntent.FLAG_ONE_SHOT
2)PendingIntent.FLAG_CANCEL_CURRENT
3)0
通知标志始终设置为
notification.flags |=
Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
感谢
答案 0 :(得分:1)
我猜你的代码看起来像下面的代码:
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
<some other code>
private static final int ID = 1;
mNotificationManager.notify(ID, notification);
如果是这样,请尝试将“ID”更改为每个通知的唯一身份。