Set groupKey for media notification in DefaultMediaNotificationProvider
By doing so, the media notification sent from DefaultMediaNotificationProvider won't be auto-grouped (https://developer.android.com/develop/ui/views/notifications/group#automatic-grouping) with the regular notifications sent from the other places in the app. As the result, when the customer attempts to dismiss the regular notifications (by swiping away), the media notification won't be dismissed as being in the same group. Issue: androidx/media#549 PiperOrigin-RevId: 561047571
This commit is contained in:
parent
5a6b88d751
commit
32e367fabf
@ -237,6 +237,13 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
|
|||||||
public static final int DEFAULT_CHANNEL_NAME_RESOURCE_ID =
|
public static final int DEFAULT_CHANNEL_NAME_RESOURCE_ID =
|
||||||
R.string.default_notification_channel_name;
|
R.string.default_notification_channel_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The group key used for the {@link NotificationCompat.Builder#setGroup(String)} to avoid the
|
||||||
|
* media notification being auto-grouped with the other notifications. The other notifications
|
||||||
|
* sent from the app shouldn't use this group key.
|
||||||
|
*/
|
||||||
|
public static final String GROUP_KEY = "media3_group_key";
|
||||||
|
|
||||||
private static final String TAG = "NotificationProvider";
|
private static final String TAG = "NotificationProvider";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@ -385,6 +392,7 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
|
|||||||
.setStyle(mediaStyle)
|
.setStyle(mediaStyle)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
.setOngoing(false)
|
.setOngoing(false)
|
||||||
|
.setGroup(GROUP_KEY)
|
||||||
.build();
|
.build();
|
||||||
return new MediaNotification(notificationId, notification);
|
return new MediaNotification(notificationId, notification);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user