What the purpose of setGroup() in Notification.Builder?

前端 未结 2 1835
日久生厌
日久生厌 2021-02-09 14:38

I have a some troubles with understanding of goal of setGroup() method.

As docs said :

...Grouped notifications may display in a cluster or stack on d

2条回答
  •  长发绾君心
    2021-02-09 15:36

    from the official docs:

    http://developer.android.com/preview/features/notification-updates.html

    Android N also allows you to bundle similar notifications to appear as a single notification. To make this possible, Android N uses the existing NotificationCompat.Builder.setGroup() method. Users can expand each of the notifications, and perform actions such as reply and dismiss on each of the notifications, individually from the notification shade.

    Meaning the setGroup will only make a difference if the device supports it.

    Devices that support it are:

    • Android Wear devices. when showing remote notifications, you can group together them
    • Android N. Devices running the Android N developer preview (or in the future the official N release), will show a group of notifications together

    The following blog post shows how those work on Android N: https://medium.com/exploring-android/android-n-introducing-upgraded-notifications-d4dd98a7ca92

    bellow is a render of that a group looks like:

    That means that setGroup will make no difference on devices running anything bellow API23, that includes, Marshamallow, Lollipop, KitKat, etc.

提交回复
热议问题