Notification with setGroupSummary(true) is not visible in Android N

懵懂的女人 提交于 2020-01-22 18:51:54

问题


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,

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

Any help will be really appreciated.


回答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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/38097442/notification-with-setgroupsummarytrue-is-not-visible-in-android-n

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