public final class

CommandButton.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.session.CommandButton.Builder

Overview

A builder for CommandButton.

Summary

Constructors
publicBuilder()

Creates a builder.

Methods
public CommandButtonbuild()

Builds a CommandButton.

public CommandButton.BuildersetDisplayName(java.lang.CharSequence displayName)

Sets a display name of this button.

public CommandButton.BuildersetEnabled(boolean enabled)

Sets whether the button is enabled.

public CommandButton.BuildersetExtras(Bundle extras)

Sets an extra of this button.

public CommandButton.BuildersetIconResId(int resId)

Sets the resource id of a bitmap (e.g.

public CommandButton.BuildersetPlayerCommand(int playerCommand)

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

public CommandButton.BuildersetSessionCommand(SessionCommand sessionCommand)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a builder.

Methods

public CommandButton.Builder setSessionCommand(SessionCommand sessionCommand)

Sets the SessionCommand that will be sent to the session when the button is clicked. Cannot set this if player command is already set via CommandButton.Builder.setPlayerCommand(int).

Parameters:

sessionCommand: The session command.

Returns:

This builder for chaining.

public CommandButton.Builder setPlayerCommand(int playerCommand)

Sets the that would be sent to the session when the button is clicked. Cannot set this if session command is already set via CommandButton.Builder.setSessionCommand(SessionCommand).

Parameters:

playerCommand: The player command.

Returns:

This builder for chaining.

public CommandButton.Builder setIconResId(int resId)

Sets the resource id of a bitmap (e.g. PNG) icon of this button.

Non-bitmap (e.g. VectorDrawable) may cause unexpected behavior in a MediaController app, so please avoid using it especially for the older platforms (SDK_INT < 21).

Parameters:

resId: The resource id of an icon.

Returns:

This builder for chaining.

public CommandButton.Builder setDisplayName(java.lang.CharSequence displayName)

Sets a display name of this button.

Parameters:

displayName: The display name.

Returns:

This builder for chaining.

public CommandButton.Builder setEnabled(boolean enabled)

Sets whether the button is enabled.

Parameters:

enabled: Whether the button is enabled.

Returns:

This builder for chaining.

public CommandButton.Builder setExtras(Bundle extras)

Sets an extra of this button.

Parameters:

extras: The extra .

Returns:

This builder for chaining.

public CommandButton build()

Builds a CommandButton.