Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

MediaSession.CommandButton.Builder

public static final class MediaSession.CommandButton.Builder
extends Object

java.lang.Object
   ↳ androidx.media2.session.MediaSession.CommandButton.Builder


Builder for MediaSession.CommandButton.

Summary

Public constructors

MediaSession.CommandButton.Builder()

Public methods

MediaSession.CommandButton build()

Builds the MediaSession.CommandButton.

MediaSession.CommandButton.Builder setCommand(SessionCommand command)

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

MediaSession.CommandButton.Builder setDisplayName(CharSequence displayName)

Sets the display name of the button.

MediaSession.CommandButton.Builder setEnabled(boolean enabled)

Sets whether the button is enabled.

MediaSession.CommandButton.Builder setExtras(Bundle extras)

Sets the extras of the button.

MediaSession.CommandButton.Builder setIconResId(int resId)

Sets the bitmap-type (e.g.

Inherited methods

Public constructors

MediaSession.CommandButton.Builder

public MediaSession.CommandButton.Builder ()

Public methods

setCommand

public MediaSession.CommandButton.Builder setCommand (SessionCommand command)

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

Parameters
command SessionCommand: session command

Returns
MediaSession.CommandButton.Builder

setDisplayName

public MediaSession.CommandButton.Builder setDisplayName (CharSequence displayName)

Sets the display name of the button.

Parameters
displayName CharSequence: display name of the button

Returns
MediaSession.CommandButton.Builder

setEnabled

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

Returns
MediaSession.CommandButton.Builder

setExtras

public MediaSession.CommandButton.Builder setExtras (Bundle extras)

Sets the extras of the button.

Parameters
extras Bundle: extras information of the button

Returns
MediaSession.CommandButton.Builder

setIconResId

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

Returns
MediaSession.CommandButton.Builder