【问题标题】:Multiple notification by NotificationManagerNotificationManager 的多个通知
【发布时间】:2016-07-25 10:48:50
【问题描述】:

目前我通知用户为 -

mNotificationManager.notify("My App Name",1212,notification);

这很好用。但它在状态栏中只显示一个图标,尽管我在不同时间发送了多个通知。

我想为每个通知显示图标(即 3 个图标)。

我不确定这是否可能。有什么线索吗?

【问题讨论】:

  • 您是否对所有这些都使用相同的 notificationId?
  • 您是要生成所有通知还是为特定类型生成通知

标签: android android-notifications android-statusbar


【解决方案1】:

试试这个:

mNotificationManager.notify("My App Name",(int)(Math.random() * 101),notification);

*通知更改时相同的 id 总是最后一个

*不同的id创建一个新的通知

【讨论】:

  • 使用每次递增的计数器会更好
【解决方案2】:

根据notify documentation,如果您希望始终保持相同的 3 个通知,请尝试使用唯一标签。正是 tag 和 id 的组合使通知“覆盖”了前一个。

mNotificationManager.notify("My App Name 1",1212,notification);
mNotificationManager.notify("My App Name 2",1212,notification);
mNotificationManager.notify("My App Name 3",1212,notification);

mNotificationManager.notify("My App Name",1212,notification);
mNotificationManager.notify("My App Name",1213,notification);
mNotificationManager.notify("My App Name",1214,notification);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多