8

Tried to show 3 notification in cluster format. As per the doc, I added the setGroupSummary(true) property for the first notification.But in the result i have got only two notification. The notification which is added the GroupSummary property is not visible.

NotificationCompat.Builder firstNotification = createNotification(context,"1.Message","Here you go 1");
firstNotification .setGroupSummary(true);
firstNotification .setGroup("KEY_NOTIFICATION_GROUP");
NotificationCompat.Builder secondNotifi = createNotification(context,"2.Message","Here you go 2");
secondNotifi .setGroup("KEY_NOTIFICATION_GROUP");           
NotificationCompat.Builder thirdNotifi= createNotification(context,"3.Message","Here you go 3");
thirdNotifi.setGroup("KEY_NOTIFICATION_GROUP");

Here the notification trigger,

notificationManager =   (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,firstNotification .build());
notificationManager.notify(1,secondNotifi .build());
notificationManager.notify(2,thirdNotifi.build());

And the result is,enter image description here

I want to show all three notification in the cluster format without missing.

Any help will be really appreciated.

Community
  • 1
  • 1
Srinivasan
  • 4,481
  • 3
  • 28
  • 36
  • 1
    I'm using the final N preview and I couldn't make it work either. I set the same group on all notifications and summary true/false. The only way it works is leaving it to the system as per docs: Note: If the same app sends four or more notifications and does not specify a grouping, the system automatically groups them together. Disclosure: I'm using Urban Airship – headsvk Jul 27 '16 at 10:55
  • @headsvk yes, you are right, we can't able to implement this feature programmatically. Only the system can do this grouping as of now. – Srinivasan Jul 28 '16 at 06:28
  • I'm not an expert, but shouldn't be the responseID the same (instead of 1,2,3...). I was just reading something here: https://developer.android.com/guide/topics/ui/notifiers/notifications.html – Tobias Reich Aug 31 '16 at 15:05
  • 1
    Ah, sorry, my fault. Same ID means, the message will be overwritten. So this is not what you want. – Tobias Reich Aug 31 '16 at 15:12

3 Answers3

1

You should check the following answer : setgroup() in notification not working

You have to create a separate group notification and set the group summary flag true only for that, and that becomes the parent notification that bundles other notifications with the same group key within itself.

Community
  • 1
  • 1
1

setGroupSummary's purpose is to support API levels below Nougat. On Android 7.0 and higher, it shows a normal group and just uses the on click behavior (setContentIntent) and details like the summary text of the summary notification. On Android 7.0 and lower, it shows your summary notification as a replacement for all the other notifications the group contains.

Florian Walther
  • 6,237
  • 5
  • 46
  • 104
0

Android 7 makes a decision regarding summary notification is shown by itself. So, you want see it unless system decides that it needs to be displayed.

Solution: create a dedicated summary notification.

Lingviston
  • 5,479
  • 5
  • 35
  • 67