Always pass true for ongoing with the first notification

ISSUE: #7977
PiperOrigin-RevId: 333726625
This commit is contained in:
bachinger 2020-09-25 15:08:08 +01:00 committed by kim-vde
parent d1416aeb98
commit ea57e5d28b

View file

@ -989,7 +989,6 @@ public class PlayerNotificationManager {
Notification notification = builder.build();
notificationManager.notify(notificationId, notification);
if (!isNotificationStarted) {
isNotificationStarted = true;
context.registerReceiver(notificationBroadcastReceiver, intentFilter);
if (notificationListener != null) {
notificationListener.onNotificationStarted(notificationId, notification);
@ -997,8 +996,12 @@ public class PlayerNotificationManager {
}
@Nullable NotificationListener listener = notificationListener;
if (listener != null) {
listener.onNotificationPosted(notificationId, notification, ongoing);
// Always pass true for ongoing with the first notification to tell a service to go into
// foreground even when paused.
listener.onNotificationPosted(
notificationId, notification, ongoing || !isNotificationStarted);
}
isNotificationStarted = true;
}
// We're calling a deprecated listener method that we still want to notify.