Stay organized with collections Save and categorize content based on your preferences.

SessionToken

public final class SessionToken implements VersionedParcelable


Represents an ongoing MediaSession or a MediaSessionService. If it's representing a session service, it may not be ongoing.

This may be passed to apps by the session owner to allow them to create a MediaController to communicate with the session.

It can be also obtained by MediaSessionManager.

Summary

Constants

static final int

Type for MediaLibraryService.

static final int

Type for MediaSession.

static final int

Type for MediaSessionService.

Public constructors

SessionToken(
    @NonNull Context context,
    @NonNull ComponentName serviceComponent
)

Constructor for the token.

Constants

TYPE_LIBRARY_SERVICE

public static final int TYPE_LIBRARY_SERVICE = 2

Type for MediaLibraryService.

TYPE_SESSION

public static final int TYPE_SESSION = 0

Type for MediaSession.

TYPE_SESSION_SERVICE

public static final int TYPE_SESSION_SERVICE = 1

Type for MediaSessionService.

Public constructors

SessionToken

public SessionToken(
    @NonNull Context context,
    @NonNull ComponentName serviceComponent
)

Constructor for the token. You can create token of MediaSessionService, MediaLibraryService or MediaBrowserServiceCompat for MediaController or MediaBrowser.

Parameters
@NonNull Context context

The context.

@NonNull ComponentName serviceComponent

The component name of the service.

Public methods

equals

public boolean equals(Object obj)

getExtras

public @NonNull Bundle getExtras()
Returns
@NonNull Bundle

extras of the token

See also
setExtras

getPackageName

public @NonNull String getPackageName()
Returns
@NonNull String

package name of the session

getServiceName

public @Nullable String getServiceName()
Returns
@Nullable String

service name of the session. Can be null for TYPE_SESSION.

getType

public int getType()
Returns
int

type of the token

getUid

public int getUid()
Returns
int

uid of the session

hashCode

public int hashCode()

toString

public String toString()