zerstoer
zerstoer

Reputation: 115

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

Upvotes: 0

Views: 769

Answers (2)

Mỹ Linh Trần
Mỹ Linh Trần

Reputation: 1

you just remove .setMediaSession(sessionToken)

Upvotes: 0

Wingsong
Wingsong

Reputation: 11

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

Upvotes: 1

Related Questions