MediaRouterParams.Builder


public final class MediaRouterParams.Builder


Builder class for MediaRouterParams.

Summary

Public constructors

Constructor for builder to create MediaRouterParams.

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Public methods

@NonNull MediaRouterParams

Builds the MediaRouterParams instance.

@NonNull MediaRouterParams.Builder
setDialogType(int dialogType)

Sets the media route controller dialog type.

@NonNull MediaRouterParams.Builder

Sets whether declared MediaTransferReceiver is enabled.

@NonNull MediaRouterParams.Builder
setOutputSwitcherEnabled(boolean enabled)

Sets whether output switcher dialogs are enabled.

@NonNull MediaRouterParams.Builder
setTransferToLocalEnabled(boolean enabled)

Enables media can be transferred from remote (e.g. TV) to local (e.g. phone, Bluetooth).

Public constructors

Builder

Added in 1.2.0
public Builder()

Constructor for builder to create MediaRouterParams.

Builder

Added in 1.2.0
public Builder(@NonNull MediaRouterParams params)

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Parameters
@NonNull MediaRouterParams params

the existing instance to copy data from.

Public methods

build

Added in 1.2.0
public @NonNull MediaRouterParams build()

Builds the MediaRouterParams instance.

setDialogType

Added in 1.2.0
public @NonNull MediaRouterParams.Builder setDialogType(int dialogType)

Sets the media route controller dialog type. Default value is DIALOG_TYPE_DEFAULT.

Note that from Android R, output switcher will be used rather than the dialog type set by this method if both setOutputSwitcherEnabled output switcher} and media transfer feature are enabled.

Parameters
int dialogType

the dialog type

setMediaTransferReceiverEnabled

Added in 1.3.0
public @NonNull MediaRouterParams.Builder setMediaTransferReceiverEnabled(boolean enabled)

Sets whether declared MediaTransferReceiver is enabled. The default value is true. This method will be no-op for Android versions earlier than Android R and it stays false on devices earlier than Android R.

It can be used to disable media transfer feature when MediaTransferReceiver is declared. If set to false, media transfer feature will be disabled even when MediaTransferReceiver is declared.

It is not recommended to change this value at runtime. It could result in getting invalid routes.

setOutputSwitcherEnabled

Added in 1.2.0
public @NonNull MediaRouterParams.Builder setOutputSwitcherEnabled(boolean enabled)

Sets whether output switcher dialogs are enabled. This method will be no-op for Android versions earlier than Android R. Default value is false.

If set to true, and when media transfer is enabled, MediaRouteButton will show output switcher when clicked, no matter what type of dialog is set by setDialogType.

If set to false, MediaRouteButton will show the dialog type which is set by setDialogType.

setTransferToLocalEnabled

Added in 1.2.0
public @NonNull MediaRouterParams.Builder setTransferToLocalEnabled(boolean enabled)

Enables media can be transferred from remote (e.g. TV) to local (e.g. phone, Bluetooth). Apps that enabling this feature should handle the case in their callback properly. Default value is false.

When this is enabled, onRouteSelected will be called whenever the 'remote to local' transfer happens, regardless of the selector provided in addCallback.

Note: This method will be no-op for Android versions earlier than Android R. It has effect only when media transfer is enabled.