SessionToken

Added in 1.0.0
Deprecated in 1.3.0

public final class SessionToken implements VersionedParcelable


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 to communicate with the session.

It can be also obtained by MediaSessionManager.

Summary

Constants

static final int

Type for MediaLibraryService.

static final int

Type for MediaSession.

static final int

Type for MediaSessionService.

Public constructors

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

Constructor for the token.

Constants

TYPE_LIBRARY_SERVICE

Added in 1.0.0
Deprecated in 1.3.0
public static final int TYPE_LIBRARY_SERVICE = 2

Type for MediaLibraryService.

TYPE_SESSION

Added in 1.0.0
Deprecated in 1.3.0
public static final int TYPE_SESSION = 0

Type for MediaSession.

TYPE_SESSION_SERVICE

Added in 1.0.0
Deprecated in 1.3.0
public static final int TYPE_SESSION_SERVICE = 1

Type for MediaSessionService.

Public constructors

SessionToken

Added in 1.0.0
Deprecated in 1.3.0
public SessionToken(
    @NonNull Context context,
    @NonNull ComponentName serviceComponent
)

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

Parameters
@NonNull Context context

The context.

@NonNull ComponentName serviceComponent

The component name of the service.

Public methods

equals

public boolean equals(Object obj)

getExtras

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull Bundle getExtras()
Returns
@NonNull Bundle

extras of the token

See also
setExtras

getPackageName

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull String getPackageName()
Returns
@NonNull String

package name of the session

getServiceName

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable String getServiceName()
Returns
@Nullable String

service name of the session. Can be null for TYPE_SESSION.

getType

Added in 1.0.0
Deprecated in 1.3.0
public int getType()
Returns
int

type of the token

getUid

Added in 1.0.0
Deprecated in 1.3.0
public int getUid()
Returns
int

uid of the session

hashCode

public int hashCode()

toString

public String toString()