Builder

class Builder
kotlin.Any
   ↳ androidx.media.MediaSession2.CommandButton.Builder

Builder for CommandButton.

Summary

Public constructors

Public methods
MediaSession2.CommandButton.Builder
setEnabled(enabled: Boolean)

Sets whether the button is enabled.

MediaSession2.CommandButton.Builder
setExtras(extras: Bundle?)

Sets the extras of the button.

MediaSession2.CommandButton.Builder
setIconResId(resId: Int)

Sets the bitmap-type (e.

MediaSession2.CommandButton.Builder

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

MediaSession2.CommandButton.Builder
setDisplayName(displayName: String?)

Sets the display name of the button.

MediaSession2.CommandButton

Builds the CommandButton.

Public constructors

<init>

Builder()

Public methods

setEnabled

fun setEnabled(enabled: Boolean): MediaSession2.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

fun setExtras(extras: Bundle?): MediaSession2.CommandButton.Builder

Sets the extras of the button.

Parameters
extras Bundle?: extras information of the button

setIconResId

fun setIconResId(resId: Int): MediaSession2.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 MediaController2 app, so please avoid using it especially for the older platform (API < 21).

Parameters
resId Int: resource id of the button

setCommand

fun setCommand(command: SessionCommand2?): MediaSession2.CommandButton.Builder

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

Parameters
command SessionCommand2?: session command

setDisplayName

fun setDisplayName(displayName: String?): MediaSession2.CommandButton.Builder

Sets the display name of the button.

Parameters
displayName String?: display name of the button