belongs to Maven artifact androidx.media:media:1.0.0-alpha1

SessionToken2

public final class SessionToken2
extends Object

java.lang.Object
   ↳ androidx.media.SessionToken2


Represents an ongoing MediaSession2 or a MediaSessionService2. 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 MediaController2 to communicate with the session.

It can be also obtained by MediaSessionManager.

Summary

Constants

int TYPE_LIBRARY_SERVICE

Type for MediaLibraryService2.

int TYPE_SESSION

Type for MediaSession2.

int TYPE_SESSION_SERVICE

Type for MediaSessionService2.

Public constructors

SessionToken2(Context context, ComponentName serviceComponent)

Constructor for the token.

Public methods

boolean equals(Object obj)
static SessionToken2 fromBundle(Bundle bundle)

Create a token from the bundle, exported by toBundle().

String getId()
String getPackageName()
String getServiceName()
int getType()
int getUid()
int hashCode()
Bundle toBundle()

Create a Bundle from this token to share it across processes.

String toString()

Inherited methods

Constants

TYPE_LIBRARY_SERVICE

int TYPE_LIBRARY_SERVICE

Type for MediaLibraryService2.

Constant Value: 2 (0x00000002)

TYPE_SESSION

int TYPE_SESSION

Type for MediaSession2.

Constant Value: 0 (0x00000000)

TYPE_SESSION_SERVICE

int TYPE_SESSION_SERVICE

Type for MediaSessionService2.

Constant Value: 1 (0x00000001)

Public constructors

SessionToken2

SessionToken2 (Context context, 
                ComponentName serviceComponent)

Constructor for the token. You can only create token for session service or library service to use by MediaController2 or MediaBrowser2.

Parameters
context Context: The context.

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

Public methods

equals

boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

fromBundle

SessionToken2 fromBundle (Bundle bundle)

Create a token from the bundle, exported by toBundle().

Returns
SessionToken2

getId

String getId ()

Returns
String id

getPackageName

String getPackageName ()

Returns
String package name

getServiceName

String getServiceName ()

Returns
String service name. Can be null for TYPE_SESSION.

getType

int getType ()

Returns
int type of the token

getUid

int getUid ()

Returns
int uid of the session

hashCode

int hashCode ()

Returns
int

toBundle

Bundle toBundle ()

Create a Bundle from this token to share it across processes.

Returns
Bundle Bundle

toString

String toString ()

Returns
String