Tapping on a bundled notification doesn't trigger the PendingIntent

倖福魔咒の 提交于 2020-01-22 11:46:28

问题


So in Nougat multiple notifications from the same app get automatically bundled into a group. I'm setting a PendingIntent with some extras on my notifications and if a specific notification is tapped, it launches a specific activity (deep linking).

However, if I tap on the notification bundle (i.e. without expanding the group) my app is simply launched as if it was from the launcher - i.e. its intent is empty, there are no extras (it is not launched via the provided PendingIntent).

How can I specify an intent to use when user taps on a notification bundle?


回答1:


I faced the same issue and after some investigation, it seems you cannot set a PendingIntent to be used when Android decides to automatically group the notifications.

The implementation is at NotificationManagerService.maybeAddAutobundleSummary() in AOSP sources. In this situation the system always generates a PendingIntent to just launch the launcher activity.

What you could do manage the grouping and summary notifications yourself, such as described here: http://blog.danlew.net/2017/02/07/correctly-handling-bundled-android-notifications/

Another option would be to iterate through active notifications using NotificationManager.getActiveNotifications() when the app is launched and then decide what to do (e.g. handle a pending deep link if found).



来源:https://stackoverflow.com/questions/43526757/tapping-on-a-bundled-notification-doesnt-trigger-the-pendingintent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!