SessionCommand


public final class SessionCommand


A command that a MediaController can send to a MediaSession.

If commandCode isn't COMMAND_CODE_CUSTOM, it's a predefined command. If commandCode is COMMAND_CODE_CUSTOM, it's a custom command and customAction must not be null.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = TYPE_USE)
@IntDef(value = )
public annotation SessionCommand.CommandCode

Command codes of session commands.

Constants

static final int

Command code for the custom command which can be defined by string action in the .

static final int

Command code for getChildren.

static final int

Command code for getItem.

static final int

Command code for getLibraryRoot.

static final int

Command code for getSearchResult.

static final int

Command code for search.

static final int

Command code for subscribe.

static final int

Command code for unsubscribe.

static final int

Command code for setRating.

Public fields

final int

The command code of a predefined command.

final String

The action of a custom command.

final Bundle

The extra bundle of a custom command.

Public constructors

Creates a predefined command.

SessionCommand(String action, Bundle extras)

Creates a custom command.

Public methods

boolean

Checks the given session command for equality while ignoring extras.

static SessionCommand

Restores a SessionCommand from a Bundle.

int
Bundle

Constants

COMMAND_CODE_CUSTOM

public static final int COMMAND_CODE_CUSTOM = 0

Command code for the custom command which can be defined by string action in the .

COMMAND_CODE_LIBRARY_GET_CHILDREN

public static final int COMMAND_CODE_LIBRARY_GET_CHILDREN = 50003

Command code for getChildren.

COMMAND_CODE_LIBRARY_GET_ITEM

public static final int COMMAND_CODE_LIBRARY_GET_ITEM = 50004

Command code for getItem.

COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT

public static final int COMMAND_CODE_LIBRARY_GET_LIBRARY_ROOT = 50000

Command code for getLibraryRoot.

COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT

public static final int COMMAND_CODE_LIBRARY_GET_SEARCH_RESULT = 50006

Command code for getSearchResult.

COMMAND_CODE_LIBRARY_SEARCH

public static final int COMMAND_CODE_LIBRARY_SEARCH = 50005

Command code for search.

COMMAND_CODE_LIBRARY_SUBSCRIBE

public static final int COMMAND_CODE_LIBRARY_SUBSCRIBE = 50001

Command code for subscribe.

COMMAND_CODE_LIBRARY_UNSUBSCRIBE

public static final int COMMAND_CODE_LIBRARY_UNSUBSCRIBE = 50002

Command code for unsubscribe.

COMMAND_CODE_SESSION_SET_RATING

public static final int COMMAND_CODE_SESSION_SET_RATING = 40010

Command code for setRating.

Public fields

commandCode

@SessionCommand.CommandCode
public final int commandCode

The command code of a predefined command. It will be COMMAND_CODE_CUSTOM for a custom command.

customAction

public final String customAction

The action of a custom command. It will be an empty string for a predefined command.

customExtras

public final Bundle customExtras

The extra bundle of a custom command. It will be EMPTY for a predefined command.

Interoperability: This value is not used when the command is sent to a legacy android.support.v4.media.session.MediaSessionCompat or android.support.v4.media.session.MediaControllerCompat.

Public constructors

SessionCommand

public SessionCommand(@SessionCommand.CommandCode int commandCode)

Creates a predefined command.

Parameters
@SessionCommand.CommandCode int commandCode

A command code for a predefined command.

SessionCommand

public SessionCommand(String action, Bundle extras)

Creates a custom command.

Parameters
String action

The action of this custom command.

Bundle extras

An extra bundle for this custom command. This value is not used when the command is sent to a legacy android.support.v4.media.session.MediaSessionCompat or android.support.v4.media.session.MediaControllerCompat.

Public methods

equals

public boolean equals(@Nullable Object obj)

Checks the given session command for equality while ignoring extras.

fromBundle

@UnstableApi
public static SessionCommand fromBundle(Bundle bundle)

Restores a SessionCommand from a Bundle.

hashCode

public int hashCode()

toBundle

@UnstableApi
public Bundle toBundle()