The Android Developer Challenge is back! Submit your idea before December 2.

Builder

class Builder
kotlin.Any
   ↳ androidx.media2.session.MediaSession.CommandButton.Builder

Builder for CommandButton.

Summary

Public constructors

Builder for CommandButton.

Public methods

MediaSession.CommandButton

Builds the CommandButton.

MediaSession.CommandButton.Builder
setCommand(@Nullable command: SessionCommand?)

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

MediaSession.CommandButton.Builder
setDisplayName(@Nullable displayName: CharSequence?)

Sets the display name of the button.

MediaSession.CommandButton.Builder
setEnabled(enabled: Boolean)

Sets whether the button is enabled.

MediaSession.CommandButton.Builder
setExtras(@Nullable extras: Bundle?)

Sets the extras of the button.

MediaSession.CommandButton.Builder
setIconResId(resId: Int)

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

Public constructors

<init>

Builder()

Builder for CommandButton.

Public methods

build

@NonNull fun build(): MediaSession.CommandButton

Builds the CommandButton.

Return
MediaSession.CommandButton: a new CommandButton

setCommand

@NonNull fun setCommand(@Nullable command: SessionCommand?): MediaSession.CommandButton.Builder

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

Parameters
command SessionCommand?: session command

setDisplayName

@NonNull fun setDisplayName(@Nullable displayName: CharSequence?): MediaSession.CommandButton.Builder

Sets the display name of the button.

Parameters
displayName CharSequence?: display name of the button

setEnabled

@NonNull fun setEnabled(enabled: Boolean): MediaSession.CommandButton.Builder

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

Parameters
enabled Boolean: true if the button is enabled and ready. false otherwise.

setExtras

@NonNull fun setExtras(@Nullable extras: Bundle?): MediaSession.CommandButton.Builder

Sets the extras of the button.

Parameters
extras Bundle?: extras information of the button

setIconResId

@NonNull fun setIconResId(resId: Int): MediaSession.CommandButton.Builder

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
resId Int: resource id of the button