How can I disable the Android 11 media notification for my application when using ExoPlayer's media2 extension?

578 Views Asked by At

I have an application that plays videos using ExoPlayer. A notification is created using the PlayerNotificationManager and MediaDescriptionAdapter from ExoPlayer.

On Android 11 on a Pixel 5 (but not a Pixel 3 XL) or any Samsung device I see two notifications: one that I see on all other OS versions, and one that appears in the settings tray on a Pixel, or the Media section (and lock screen) on Samsung devices.

At some point, I would like to support that notification properly, but for now, having two notifications is a bug, and it seems like the easiest fix should be to disable the new notification.

The linked documentation says

To be discoverable your app must provide a MediaBrowserService, typically using the MediaBrowserServiceCompat library from Android Jetpack.

My app has an androidx.media2.MediaSessionService, which hides the MediaBrowserService. I have tried returning null from the onGetSession() method, but the notification still appears. It seems like I need a way to do the equivalent of returning null from onGetRoot().

Is there anything I can do to opt out of this notification without rewriting all of my MediaSession/MediaSessionService code to use the older compat equivalents?

0

There are 0 best solutions below