The Android Developer Challenge is back! Submit your idea before December 2.

MediaSessionManager

class MediaSessionManager
kotlin.Any
   ↳ androidx.media.MediaSessionManager

Provides support for interacting with media sessions that applications have published to express their ongoing media playback state.

Summary

Nested classes

Information of a remote user of MediaSessionCompat or MediaBrowserServiceCompat.

Public methods

static MediaSessionManager
getSessionManager(@NonNull context: Context)

Gets an instance of the media session manager associated with the context.

Boolean

Checks whether the remote user is a trusted app.

Public methods

getSessionManager

@NonNull static fun getSessionManager(@NonNull context: Context): MediaSessionManager

Gets an instance of the media session manager associated with the context.

Return
MediaSessionManager: The MediaSessionManager instance for this context.

isTrustedForMediaControl

fun isTrustedForMediaControl(@NonNull userInfo: MediaSessionManager.RemoteUserInfo): Boolean

Checks whether the remote user is a trusted app.

An app is trusted if the app holds the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission or has an enabled notification listener.

Parameters
userInfo MediaSessionManager.RemoteUserInfo: The remote user info from either MediaSessionCompat#getCurrentControllerInfo() and MediaBrowserServiceCompat#getCurrentBrowserInfo().
Return
Boolean: true if the remote user is trusted and its package name matches with the UID. false otherwise.