Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Oreo: Grouped Notifications With Notification Channels

I followed the documentation provided here and can successfully create a notification group on Android N and higher. The issue I'm having however, is with Android Oreo, each notification posted to the group plays the sound for the group.

This is annoying because I'd just like the sound to play once. Each individual notification is a summary of the chats the user hasn't read for each chat room they're in. I need the grouping for when there are multiple chat rooms with unread messages.

There doesn't seem to be a way to set the sound for a notification dynamically, it's limited to channel creation.

I tried following what Dan Lew suggested here but the notification sound plays for each notification still.

My question therefore is, how do you get grouped notification in Android Oreo without having a notification sound play for each?

like image 488
Tunji_D Avatar asked Mar 17 '18 16:03

Tunji_D


People also ask

How can you make a list of notifications into a group notification?

Create a new notification with a description of the group—often best done with the inbox-style notification. Add the summary notification to the group by calling setGroup() . Specify that it should be used as the group summary by calling setGroupSummary(true) .

How do I stack notifications on Android?

To create a stack, call setGroup() for each notification you want in the stack and specify a group key.

How do I manage multiple notifications on Android?

Set the unique id to let Notification Manager knows this is a another notification instead of same notification. If you use the same unique Id for each notification, the Notification Manager will assume that is same notification and would replace the previous notification.


1 Answers

I'd been working for the entire week trying to solve it, but I find the answer shortly after asking on StackOverflow lol.

The answer comes courtesy of Dan Lew again, but I needed to call

  notificationBuilder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY) 

on the children notifications.

More detail can be found here.

like image 60
Tunji_D Avatar answered Sep 27 '22 19:09

Tunji_D