Register now for Android Dev Summit 2019!

SessionToken

public final class SessionToken
extends Object implements VersionedParcelable

java.lang.Object
   ↳ 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

int TYPE_LIBRARY_SERVICE

Type for MediaLibraryService.

int TYPE_SESSION

Type for MediaSession.

int TYPE_SESSION_SERVICE

Type for MediaSessionService.

Public constructors

SessionToken(Context context, ComponentName serviceComponent)

Constructor for the token.

Public methods

boolean equals(Object obj)
Bundle getExtras()
String getPackageName()
String getServiceName()
int getType()
int getUid()
int hashCode()
String toString()

Inherited methods

Constants

TYPE_LIBRARY_SERVICE

public static final int TYPE_LIBRARY_SERVICE

Type for MediaLibraryService.

Constant Value: 2 (0x00000002)

TYPE_SESSION

public static final int TYPE_SESSION

Type for MediaSession.

Constant Value: 0 (0x00000000)

TYPE_SESSION_SERVICE

public static final int TYPE_SESSION_SERVICE

Type for MediaSessionService.

Constant Value: 1 (0x00000001)

Public constructors

SessionToken

public SessionToken (Context context, 
                ComponentName serviceComponent)

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

Parameters
context Context: The context.

serviceComponent ComponentName: The component name of the service.

Public methods

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

getExtras

public Bundle getExtras ()

Returns
Bundle extras of the token

getPackageName

public String getPackageName ()

Returns
String package name of the session

getServiceName

public String getServiceName ()

Returns
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 ()

Returns
int

toString

public String toString ()

Returns
String