lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

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

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

public static final int TYPE_LIBRARY_SERVICE

Type for MediaLibraryService2.

Constant Value: 2 (0x00000002)

TYPE_SESSION

public static final int TYPE_SESSION

Type for MediaSession2.

Constant Value: 0 (0x00000000)

TYPE_SESSION_SERVICE

public static final int TYPE_SESSION_SERVICE

Type for MediaSessionService2.

Constant Value: 1 (0x00000001)

Public constructors

SessionToken2

public 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

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

fromBundle

public static SessionToken2 fromBundle (Bundle bundle)

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

Returns
SessionToken2 SessionToken2 object

getId

public String getId ()

Returns
String id

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

toBundle

public Bundle toBundle ()

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

Returns
Bundle Bundle

toString

public String toString ()

Returns
String