MediaSessionManager

Added in 1.0.0
Deprecated in 1.3.0

public final class MediaSessionManager


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

Summary

Public methods

static @NonNull MediaSessionManager

Gets an instance of MediaSessionManager associated with the context.

@NonNull Set<SessionToken>

Gets Set of SessionToken for MediaSessionService regardless of their activeness.

Public methods

getInstance

Added in 1.0.0
Deprecated in 1.3.0
public static @NonNull MediaSessionManager getInstance(@NonNull Context context)

Gets an instance of MediaSessionManager associated with the context.

Returns
@NonNull MediaSessionManager

the MediaSessionManager instance for this context

getSessionServiceTokens

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull Set<SessionTokengetSessionServiceTokens()

Gets Set of SessionToken for MediaSessionService regardless of their activeness. This list represents media apps that support background playback.

The app targeting API level 30 or higher must include a <queries> element in their manifest to get service tokens of other apps. See the following example and this guide for more information.

<intent>
  <action android:name="androidx.media2.session.MediaSessionService" />
</intent>
<intent>
  <action android:name="androidx.media2.session.MediaLibraryService" />
</intent>
<intent>
  <action android:name="android.media.browse.MediaBrowserService" />
</intent>
Returns
@NonNull Set<SessionToken>

set of tokens