Exo-player notification resets to default UI state
Issue description
Exo-player notification resets to default sometimes while changing audioTracks. While changing audioTracks we are re-setting the player instance and removing the notification manager as well. Expected behavior Exo player notification should retain the state set.
Reproduction steps
- Remove navigation and stop action from notification
playerNotificationManager.setUseNavigationActions(false);
playerNotificationManager.setStopAction(null);
- Play audio
- Switch audio files
- Itermittently default player notification is seen

Link to test content
Not public yet
Version of ExoPlayer being used
2.9.0
Device(s) and version(s) of Android being used
Seen on multiple devices including pixel 2 running Android 28, Motorola G5sPLus on oreo and more
A full bug report captured from the device
N/A
Is there a workaround for this issue?
We tried sending the large icon update to notification manager with a delay. Reduced the frequency with which we were getting this.
Another thing this is reproduced even with a simple play/pause toggle from notification. What we are doing in pause/ play: we stop the foreground service and setOngoing() to false. To enable notification to be removed.
if (!playWhenReady) {
stopForeground(false);
playerNotificationManager.setOngoing(false);
} else {
startForeground(notificationIdGlobal, notificationGlobal);
playerNotificationManager.setOngoing(true);
}
SetOngoing internally calls to invalidate() that might be the issue that sometimes we end up with a default UI state.
While changing audioTracks we are re-setting the player instance and removing the notification manager as well.
Is there a reason why you are resetting the player and remove the NotificationManager?
The state is kept in the NotificationManager. So when you do something like
playerNotificationManager.setUseNavigationActions(false);
playerNotificationManager.setStopAction(null);
the state is stored in the NotifcationManager. As long as you keep that instance the stop and navigation buttons are not shown anymore.
When you then create a new NotificationManager, like your comment suggests, you need to resume this state by calling these methods again. If you do this before you set the player again, this should actually work because the notification is only shown after the player is set again.
Is there a reason why you are resetting the player and remove the NotificationManager?
We want the notification to be removable when paused so we stop and start the foreground service accordingly. The player and NotificationManager is reset only if a new song is played. Not in the case of toggling the play pause button.
I will try and update with the suggested actions.
Issue was at our end in two places
- Loading image to display, there was a lag
- As @marcbaechinger suggested we needed to keep the same instance