Register now for Android Dev Summit 2019!

SessionToken

class SessionToken : VersionedParcelable
kotlin.Any
   ↳ androidx.media2.session.SessionToken

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 Int

Type for MediaLibraryService.

static Int

Type for MediaSession.

static Int

Type for MediaSessionService.

Public constructors

<init>(@NonNull context: Context, @NonNull serviceComponent: ComponentName)

Constructor for the token.

Public methods

Boolean
equals(other: Any?)

Bundle

String

String?

Int

Int

Int

String

Constants

TYPE_LIBRARY_SERVICE

static val TYPE_LIBRARY_SERVICE: Int

Type for MediaLibraryService.

Value: 2

TYPE_SESSION

static val TYPE_SESSION: Int

Type for MediaSession.

Value: 0

TYPE_SESSION_SERVICE

static val TYPE_SESSION_SERVICE: Int

Type for MediaSessionService.

Value: 1

Public constructors

<init>

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

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

Parameters
context Context: The context.
serviceComponent Context: The component name of the service.

Public methods

equals

fun equals(other: Any?): Boolean

getExtras

@NonNull fun getExtras(): Bundle
Return
Bundle: extras of the token

getPackageName

@NonNull fun getPackageName(): String
Return
String: package name of the session

getServiceName

@Nullable fun getServiceName(): String?
Return
String?: service name of the session. Can be null for TYPE_SESSION.

getType

fun getType(): Int
Return
Int: type of the token

getUid

fun getUid(): Int
Return
Int: uid of the session

hashCode

fun hashCode(): Int

toString

fun toString(): String