lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

belongs to Maven artifact androidx.media:media:1.0.0-alpha3

MediaSession2.CommandButton.Builder

public static final class MediaSession2.CommandButton.Builder
extends Object

java.lang.Object
   ↳ androidx.media.MediaSession2.CommandButton.Builder


Builder for MediaSession2.CommandButton.

Summary

Public constructors

MediaSession2.CommandButton.Builder()

Public methods

MediaSession2.CommandButton build()

Builds the MediaSession2.CommandButton.

MediaSession2.CommandButton.Builder setCommand(SessionCommand2 command)

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

MediaSession2.CommandButton.Builder setDisplayName(String displayName)

Sets the display name of the button.

MediaSession2.CommandButton.Builder setEnabled(boolean enabled)

Sets whether the button is enabled.

MediaSession2.CommandButton.Builder setExtras(Bundle extras)

Sets the extras of the button.

MediaSession2.CommandButton.Builder setIconResId(int resId)

Sets the bitmap-type (e.g.

Inherited methods

Public constructors

MediaSession2.CommandButton.Builder

public MediaSession2.CommandButton.Builder ()

Public methods

setCommand

public MediaSession2.CommandButton.Builder setCommand (SessionCommand2 command)

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

Parameters
command SessionCommand2: session command

Returns
MediaSession2.CommandButton.Builder

setDisplayName

public MediaSession2.CommandButton.Builder setDisplayName (String displayName)

Sets the display name of the button.

Parameters
displayName String: display name of the button

Returns
MediaSession2.CommandButton.Builder

setEnabled

public MediaSession2.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
enabled boolean: true if the button is enabled and ready. false otherwise.

Returns
MediaSession2.CommandButton.Builder

setExtras

public MediaSession2.CommandButton.Builder setExtras (Bundle extras)

Sets the extras of the button.

Parameters
extras Bundle: extras information of the button

Returns
MediaSession2.CommandButton.Builder

setIconResId

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

Parameters
resId int: resource id of the button

Returns
MediaSession2.CommandButton.Builder