public final class

MediaRouterParams.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.mediarouter.media.MediaRouterParams.Builder

Overview

Builder class for MediaRouterParams.

Summary

Constructors
publicBuilder()

Constructor for builder to create MediaRouterParams.

publicBuilder(MediaRouterParams params)

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Methods
public MediaRouterParamsbuild()

Builds the MediaRouterParams instance.

public MediaRouterParams.BuildersetDialogType(int dialogType)

Sets the media route controller dialog type.

public MediaRouterParams.BuildersetExtras(Bundle extras)

Set extras.

public MediaRouterParams.BuildersetMediaTransferReceiverEnabled(boolean enabled)

Sets whether declared MediaTransferReceiver is enabled.

public MediaRouterParams.BuildersetOutputSwitcherEnabled(boolean enabled)

Sets whether output switcher dialogs are enabled.

public MediaRouterParams.BuildersetTransferToLocalEnabled(boolean enabled)

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

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

Constructors

public Builder()

Constructor for builder to create MediaRouterParams.

public Builder(MediaRouterParams params)

Constructor for builder to create MediaRouterParams with existing MediaRouterParams instance.

Parameters:

params: the existing instance to copy data from.

Methods

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 MediaRouterParams.Builder.setOutputSwitcherEnabled(boolean) output switcher} and media transfer feature are enabled.

Parameters:

dialogType: the dialog type

See also: MediaRouterParams.Builder.setOutputSwitcherEnabled(boolean), MediaRouterParams.DIALOG_TYPE_DEFAULT, MediaRouterParams.DIALOG_TYPE_DYNAMIC_GROUP

public 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.

See also: MediaTransferReceiver

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 MediaRouterParams.Builder.setDialogType(int).

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

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.

public MediaRouterParams.Builder setExtras(Bundle extras)

Set extras. Default value is if not set.

public MediaRouterParams build()

Builds the MediaRouterParams instance.