android - Android聚合多条通知时如何动态更改通知消息?

标签 android notifications android-c2dm

我正在尝试在 Android (C2DM) 中执行这个处理推送通知的简单任务:

  • 如果通知栏中没有通知,则设置为“foo A”
  • 如果通知已经存在,捕获它,阅读它的文本,然后将它更新为类似“N 条通知:foo、bar、...”的内容。这类似于当您收到一封电子邮件与多封电子邮件时,gmail 客户端在 Android 上会执行的操作

我查看了文档,阅读了 http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating ,搜索 SO 和网络,但到目前为止,我没有看到一种方法来访问当前在通知栏中的通知。

我是否需要在别处管理计数并在用户关闭通知时重置它?没有办法读取现有的吗?

谢谢。

最佳答案

if a notification already exists, grab it, read its text, and then update it to something like "N notifications: foo, bar, ...". This is similar to what the gmail client would do on Android when you get 1 email vs multiple ones

不,不是。 Gmail 的数据库中已有此信息。它不需要“捕获[通知],阅读它的文本”。

而且,你想要的是不可能的。

Do I need to manage the count elsewhere and have it reset when the user dismisses the notification?

是的。

Is there no way to read the existing one?

没有。

关于android - Android聚合多条通知时如何动态更改通知消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4963703/

相关文章:

Android C2DM 200 错误

没有谷歌帐户的Android云到设备消息传递

java - 禁用自动旋转屏幕 - Android

Android Studio Preview 4.1 数据库检查器使应用程序崩溃

android - 启动 android 通知设置 Activity 导致泄漏的 Intent 接收器

Android - 触摸通知时提示对话框窗口

ios - ios Swift 3 app在didRegisterForRemoteNotificationsWithDeviceToken函数中崩溃

javascript - window.open 在 Firefox 55.0.1 上无法正常工作

android - 刷新后我会得到 C2DM 注册 ID 吗?

android - 如何获取谷歌热图点击监听器?