Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

SessionToken

public final class SessionToken
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.media2.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)
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 nor MediaBrowserServiceCompat for MediaController or MediaBrowser.

Parameters
context Context: The context.

serviceComponent ComponentName: The component name of the media browser service.

Public methods

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

getPackageName

public String getPackageName ()

Returns
String package name

getServiceName

public String getServiceName ()

Returns
String service name. 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