MediaSession.CommandButton.Builder

Added in 1.0.0
Deprecated in 1.3.0

public final class MediaSession.CommandButton.Builder


Builder for CommandButton.

Summary

Public constructors

Public methods

@NonNull MediaSession.CommandButton

Builds the CommandButton.

@NonNull MediaSession.CommandButton.Builder

Sets the SessionCommand that would be sent to the session when the button is clicked.

@NonNull MediaSession.CommandButton.Builder

Sets the display name of the button.

@NonNull MediaSession.CommandButton.Builder
setEnabled(boolean enabled)

Sets whether the button is enabled.

@NonNull MediaSession.CommandButton.Builder

Sets the extras of the button.

@NonNull MediaSession.CommandButton.Builder
setIconResId(int resId)

Sets the bitmap-type (e.g. PNG) icon resource id of the button.

Public constructors

Builder

Added in 1.0.0
Deprecated in 1.3.0
public Builder()

Public methods

build

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaSession.CommandButton build()

Builds the CommandButton.

setCommand

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaSession.CommandButton.Builder setCommand(@Nullable SessionCommand command)

Sets the SessionCommand that would be sent to the session when the button is clicked.

Parameters
@Nullable SessionCommand command

session command

setDisplayName

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaSession.CommandButton.Builder setDisplayName(@Nullable CharSequence displayName)

Sets the display name of the button.

Parameters
@Nullable CharSequence displayName

display name of the button

setEnabled

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaSession.CommandButton.Builder setEnabled(boolean enabled)

Sets whether the button is enabled. Can be false to indicate that the button should be shown but isn't clickable.

Parameters
boolean enabled

true if the button is enabled and ready. false otherwise.

setExtras

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaSession.CommandButton.Builder setExtras(@Nullable Bundle extras)

Sets the extras of the button.

Parameters
@Nullable Bundle extras

extras information of the button

setIconResId

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaSession.CommandButton.Builder setIconResId(int resId)

Sets the bitmap-type (e.g. PNG) icon resource id of the button.

None bitmap type (e.g. VectorDrawabale) may cause unexpected behavior when it's sent to MediaController app, so please avoid using it especially for the older platform (API <21).

Parameters
int resId

resource id of the button