通知仅在第一次时显示在通知区域中
假设我的应用程序发布了一个带有文本“hello”的状态栏通知。 “你好”通知在通知区域中显示良好。
现在,如果我的应用程序再次发布“hello”,而第一个“hello”仍在通知区域中,则通知区域仍包含单个“hello”通知, 这也很好。
但现在,如果第一个“hello”通知从通知区域取消(删除),然后 第二个“你好”通知已发布,我希望通知区域显示 再次出现(第二个)“你好”通知,但它没有显示任何“你好”通知。
这是为什么?我该如何解决这个问题?
这就是我所做的: 在发布通知之前我总是: Intent.setAction(""+new Date().getTime()); 我创建了一个内容意图,如下所示:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, flag);
我尝试了“标志”的所有以下值,但没有一个可以解决问题:
1) PendingIntent.FLAG_ONE_SHOT
2) PendingIntent.FLAG_CANCEL_CURRENT
3) 0
通知标志始终设置为
notification.flags |=
Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
感谢
suppose my application posts a status bar notification with the text "hello".
that "hello" notification shows fine in the notification area.
now if my application posts "hello" again while the first "hello" is still in the notification area, the notification area still contains a single "hello" notification,
and that's fine too.
But now, if the first "hello" notification is canceled (removed) from the notification area and then
the 2nd "hello" notification is posted, i would expect the notification area to show
the (2nd) "hello" notification again, but it does not show any "hello" notification.
why is that and how can i get around this problem?
this is what i've done:
before posting a notification i always:
intent.setAction(""+new Date().getTime());
and i create a content intent as in:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, flag);
i tried all the following values for 'flag' but none of them solves the problem:
1) PendingIntent.FLAG_ONE_SHOT
2) PendingIntent.FLAG_CANCEL_CURRENT
3) 0
the notification flags are always set to
notification.flags |=
Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您的代码类似于下面的代码:
如果是这样,请尝试将“ID”更改为每个通知的唯一性。
I'm guessing your code looks something like the code below:
if so, try changing the 'ID' to be unique for each notification.