MediaSessionManager

public final class MediaSessionManager


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

Summary

Nested types

Information of a remote user of MediaSessionCompat or MediaBrowserServiceCompat.

Public methods

static @NonNull MediaSessionManager

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

Added in 1.1.0
public static @NonNull MediaSessionManager getSessionManager(@NonNull Context context)

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

Returns
@NonNull MediaSessionManager

The MediaSessionManager instance for this context.

isTrustedForMediaControl

Added in 1.1.0
public boolean isTrustedForMediaControl(
    @NonNull MediaSessionManager.RemoteUserInfo userInfo
)

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
@NonNull MediaSessionManager.RemoteUserInfo userInfo

The remote user info from either getCurrentControllerInfo and getCurrentBrowserInfo.

Returns
boolean

true if the remote user is trusted and its package name matches with the UID. false otherwise.