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

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

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:

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.



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