'Android 11 - Notification media controls doesn't show on lock screen

Notification media controls doesn't show on lock screen for Samsung Devices S10/A20 with Android 11, but for other devices different than Samsung works well.

This code doesn't allow to show it on Lock Screen but if I remove it, works without any style:

   setStyle(
     MediaStyle()
       .setMediaSession(sessionToken)
       .setShowActionsInCompactView(*actionsToShow.toIntArray())
   )

I'm using NotificationCompat.Builder to create the notification.

I would like to know how can I fix that?

Thanks in advance



Solution 1:[1]

I had the same issue. My solution was to set the corresponding playback state on my media session:

mediaSession.setPlaybackState(
        PlaybackStateCompat.Builder()
            .setState(PlaybackStateCompat.STATE_PLAYING, 0, 1f)
            .build()
    )

Same goes for PlaybackStateCompat.STATE_PAUSED

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wingsong