Google is committed to advancing racial equity for Black communities. See how.

MediaRouterParams.Builder

public static final class MediaRouterParams.Builder
extends Object

java.lang.Object
   ↳ androidx.mediarouter.media.MediaRouterParams.Builder


Builder class for MediaRouterParams.

Summary

Public constructors

Builder()

Constructor for builder to create MediaRouterParams.

Builder(MediaRouterParams params)

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Public methods

MediaRouterParams build()

Builds the MediaRouterParams instance.

MediaRouterParams.Builder setDialogType(int dialogType)

Sets the media route controller dialog type.

MediaRouterParams.Builder setOutputSwitcherEnabled(boolean enabled)

Sets whether output switcher dialogs are enabled.

MediaRouterParams.Builder setTransferToLocalEnabled(boolean enabled)

Enables media can be transferred from remote (e.g.

Inherited methods

Public constructors

Builder

public Builder ()

Constructor for builder to create MediaRouterParams.

Builder

public Builder (MediaRouterParams params)

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Parameters
params MediaRouterParams: the existing instance to copy data from.

Public methods

build

public MediaRouterParams build ()

Builds the MediaRouterParams instance.

Returns
MediaRouterParams

setDialogType

public MediaRouterParams.Builder setDialogType (int dialogType)

Sets the media route controller dialog type. Default value is MediaRouterParams.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(boolean) output switcher} and media transfer feature are enabled.

Parameters
dialogType int: the dialog type

Returns
MediaRouterParams.Builder

setOutputSwitcherEnabled

public 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(int).

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

Parameters
enabled boolean

Returns
MediaRouterParams.Builder

setTransferToLocalEnabled

public 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, MediaRouter.Callback.onRouteSelected(MediaRouter, MediaRouter.RouteInfo, int, MediaRouter.RouteInfo) will be called whenever the 'remote to local' transfer happens, regardless of the selector provided in MediaRouter.addCallback(MediaRouteSelector, MediaRouter.Callback).

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

Parameters
enabled boolean

Returns
MediaRouterParams.Builder