android - 从 Android 通知中获取详细信息/扩展文本?

标签 android notifications android-notifications

我已经实现了一个通知监听器来寻找 Gmail 通知。

我想从通知中收集扩展文本(大文本),如下面的通知所示:

Expanded text shown in gmail notification

请参阅“----转发的消息---”等,它仅在用户展开通知以显示操作按钮时出现。

此字符串值未出现在通知的“EXTRAS”数据中...

http://developer.android.com/reference/android/app/Notification.html

最佳答案

查看以上链接后,我进一步调查了 bundle (EXTRAS) 数据。当你调试它并查看变量时,你会发现所有关于通知的信息都存储在包中,你可以通过

获取详细信息

notifyBundle.extras.getCharSequence("android.textLines") 用于多行通知和

notifyBundle.extras.getString("android.text") 用于单行通知。

更多信息,看eclipse Debug模式下的变量

Image of variables in bundle for single line notification

Image of variables in bundle for multi line notification

注意:额外的 bundle 仅在 API19 (Kitkat) 中可用。我从未在低于 API19 的设备上尝试过。

关于android - 从 Android 通知中获取详细信息/扩展文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22330809/

相关文章:

php - 带列表的 Redis 通知

notifications - Laravel 更改通知表的连接

android - 从服务通知恢复应用程序

android - WebView : how to avoid security alert from Google Play upon implementation of onReceivedSslError

android - 自定义选项卡指示器(像指示器一样向下箭头)

android - 更新本地 Android 数据库

macos - 右上角通知HUD窗口

android - 没有收到通知

android - 从通知打开应用程序时如何应用正常 Activity 顺序

android - 如何在android中拆分相机预览?