Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tapping on a bundled notification doesn't trigger the PendingIntent

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?

like image 516
Dennis K Avatar asked Apr 20 '17 18:04

Dennis K


1 Answers

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).

like image 94
Teemu Rossi Avatar answered Nov 10 '22 14:11

Teemu Rossi