public class

MediaRouter.RouteInfo

extends java.lang.Object

 java.lang.Object

↳androidx.mediarouter.media.MediaRouter.RouteInfo

Overview

Provides information about a media route.

Each media route has a list of media control intent filters that describe the capabilities of the route and the manner in which it is used and controlled.

Summary

Fields
public static final intCONNECTION_STATE_CONNECTED

A connection state indicating the route is connected.

public static final intCONNECTION_STATE_CONNECTING

A connection state indicating the route is in the process of connecting and is not yet ready for use.

public static final intCONNECTION_STATE_DISCONNECTED

The default connection state indicating the route is disconnected.

public static final intDEVICE_TYPE_AUDIO_VIDEO_RECEIVER

A receiver device type indicating that the presentation of the media is happening on an Audio/Video receiver (AVR).

public static final intDEVICE_TYPE_BLE_HEADSET

A receiver device type indicating the presentation of the media is happening on a Bluetooth Low Energy (BLE) HEADSET.

public static final intDEVICE_TYPE_BLUETOOTH_A2DP

A receiver device type of the route indicating the presentation of the media is happening on a bluetooth device such as a bluetooth speaker.

public static final intDEVICE_TYPE_BUILTIN_SPEAKER

A receiver device type indicating the presentation of the media is happening on a speaker system (i.e.

public static final intDEVICE_TYPE_CAR

A receiver device type indicating that the presentation of the media is happening on a car.

public static final intDEVICE_TYPE_COMPUTER

A receiver device type indicating that the presentation of the media is happening on a computer.

public static final intDEVICE_TYPE_DOCK

A receiver device type indicating the presentation of the media is happening on an audio device associated on a dock.

public static final intDEVICE_TYPE_GAME_CONSOLE

A receiver device type indicating that the presentation of the media is happening on a gaming console.

public static final intDEVICE_TYPE_GROUP

A receiver device type indicating that the presentation of the media is happening on a group of devices.

public static final intDEVICE_TYPE_HDMI

A receiver device type indicating the presentation of the media is happening on an HDMI connection.

public static final intDEVICE_TYPE_HDMI_ARC

A receiver device type indicating the presentation of the media is happening on an Audio Return Channel of an HDMI connection

public static final intDEVICE_TYPE_HDMI_EARC

A receiver device type indicating the presentation of the media is happening on an Enhanced Audio Return Channel of an HDMI connection

public static final intDEVICE_TYPE_HEARING_AID

A receiver device type indicating the presentation of the media is happening on a hearing aid device.

public static final intDEVICE_TYPE_REMOTE_SPEAKER

A receiver device type of the route indicating the presentation of the media is happening on a remote speaker.

public static final intDEVICE_TYPE_SMARTPHONE

A receiver device type indicating that the presentation of the media is happening on a smartphone.

public static final intDEVICE_TYPE_SMARTWATCH

A receiver device type indicating that the presentation of the media is happening on a smartwatch.

public static final intDEVICE_TYPE_SPEAKER

A receiver device type of the route indicating the presentation of the media is happening on a speaker.

public static final intDEVICE_TYPE_TABLET

A receiver device type indicating that the presentation of the media is happening on a tablet.

public static final intDEVICE_TYPE_TABLET_DOCKED

A receiver device type indicating that the presentation of the media is happening on a docked tablet.

public static final intDEVICE_TYPE_TV

A receiver device type of the route indicating the presentation of the media is happening on a TV.

public static final intDEVICE_TYPE_UNKNOWN

The default receiver device type of the route indicating the type is unknown.

public static final intDEVICE_TYPE_USB_ACCESSORY

A receiver device type indicating the presentation of the media is happening on a USB audio device in accessory mode.

public static final intDEVICE_TYPE_USB_DEVICE

A receiver device type indicating the presentation of the media is happening on a USB audio device.

public static final intDEVICE_TYPE_USB_HEADSET

A receiver device type indicating the presentation of the media is happening on a USB audio headset.

public static final intDEVICE_TYPE_WIRED_HEADPHONES

A receiver device type indicating the presentation of the media is happening on a pair of wired headphones.

public static final intDEVICE_TYPE_WIRED_HEADSET

A receiver device type indicating the presentation of the media is happening on a headset, which is the combination of a headphones and a microphone.

public static final intPLAYBACK_TYPE_LOCAL

The default playback type, "local", indicating the presentation of the media is happening on the same device (e.g.

public static final intPLAYBACK_TYPE_REMOTE

A playback type indicating the presentation of the media is happening on a different device (i.e.

public static final intPLAYBACK_VOLUME_FIXED

Playback information indicating the playback volume is fixed, i.e.

public static final intPLAYBACK_VOLUME_VARIABLE

Playback information indicating the playback volume is variable and can be controlled from this object.

public static final intPRESENTATION_DISPLAY_ID_NONE

The default presentation display id indicating no presentation display is associated with the route.

Methods
public booleancanDisconnect()

Gets whether this route supports disconnecting without interrupting playback.

public intgetConnectionState()

Gets the connection state of the route.

public java.util.List<IntentFilter>getControlFilters()

Gets a list of media control intent filters that describe the capabilities of this route and the media control actions that it supports.

public java.lang.StringgetDescription()

Gets the user-visible description of the route.

public intgetDeviceType()

Gets the type of the receiver device associated with this route.

public MediaRouteProvider.DynamicGroupRouteControllergetDynamicGroupController()

public MediaRouter.RouteInfo.DynamicGroupStategetDynamicGroupState(MediaRouter.RouteInfo route)

Gets the dynamic group state of the given route.

public BundlegetExtras()

Gets a collection of extra properties about this route that were supplied by its media route provider, or null if none.

public UrigetIconUri()

Gets the URI of the icon representing this route.

public java.lang.StringgetId()

Gets the unique id of the route.

public java.util.List<MediaRouter.RouteInfo>getMemberRoutes()

Returns the routes in this group

public java.lang.StringgetName()

Gets the user-visible name of the route.

public intgetPlaybackStream()

Gets the audio stream over which the playback associated with this route is performed.

public intgetPlaybackType()

Gets the type of playback associated with this route.

public DisplaygetPresentationDisplay()

Gets the Display that should be used by the application to show a on an external display when this route is selected.

public intgetPresentationDisplayId()

Gets the route's presentation display id, or -1 if none.

public MediaRouter.ProviderInfogetProvider()

Gets information about the provider of this media route.

public MediaRouteProvidergetProviderInstance()

public IntentSendergetSettingsIntent()

Gets an intent sender for launching a settings activity for this route.

public intgetVolume()

Gets the current volume for this route.

public intgetVolumeHandling()

Gets information about how volume is handled on the route.

public intgetVolumeMax()

Gets the maximum volume at which the playback associated with this route is performed.

public booleanisBluetooth()

Returns true if this route is a bluetooth route.

public booleanisConnecting()

Returns true if the route is in the process of connecting and is not yet ready for use.

public booleanisDefault()

Returns true if this route is the default route.

public booleanisDefaultOrBluetooth()

public booleanisDeviceSpeaker()

Returns true if this route is the default route and the device speaker.

public booleanisEnabled()

Returns true if this route is enabled and may be selected.

public booleanisGroup()

Returns true if the route has one or more members

public booleanisSelected()

Returns true if this route is currently selected.

public booleanisSystemRoute()

Returns true if this route is a system route.

public booleanmatchesSelector(MediaRouteSelector selector)

Returns true if the route supports at least one of the capabilities described by a media route selector.

public voidrequestSetVolume(int volume)

Requests a volume change for this route asynchronously.

public voidrequestUpdateVolume(int delta)

Requests an incremental volume update for this route asynchronously.

public voidselect()

Selects this media route.

public voidsendControlRequest(Intent intent, MediaRouter.ControlRequestCallback callback)

Sends a media control request to be performed asynchronously by the route's destination.

public booleansupportsControlAction(java.lang.String category, java.lang.String action)

Returns true if the route supports the specified media control category and action.

public booleansupportsControlCategory(java.lang.String category)

Returns true if the route supports the specified media control category.

public booleansupportsControlRequest(Intent intent)

Returns true if the route supports the specified media control request.

public java.lang.StringtoString()

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

Fields

public static final int CONNECTION_STATE_DISCONNECTED

The default connection state indicating the route is disconnected.

See also: MediaRouter.RouteInfo.getConnectionState()

public static final int CONNECTION_STATE_CONNECTING

A connection state indicating the route is in the process of connecting and is not yet ready for use.

See also: MediaRouter.RouteInfo.getConnectionState()

public static final int CONNECTION_STATE_CONNECTED

A connection state indicating the route is connected.

See also: MediaRouter.RouteInfo.getConnectionState()

public static final int PLAYBACK_TYPE_LOCAL

The default playback type, "local", indicating the presentation of the media is happening on the same device (e.g. a phone, a tablet) as where it is controlled from.

See also: MediaRouter.RouteInfo.getPlaybackType()

public static final int PLAYBACK_TYPE_REMOTE

A playback type indicating the presentation of the media is happening on a different device (i.e. the remote device) than where it is controlled from.

See also: MediaRouter.RouteInfo.getPlaybackType()

public static final int DEVICE_TYPE_UNKNOWN

The default receiver device type of the route indicating the type is unknown.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_TV

A receiver device type of the route indicating the presentation of the media is happening on a TV.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_SPEAKER

Deprecated: use MediaRouter.RouteInfo.DEVICE_TYPE_BUILTIN_SPEAKER and MediaRouter.RouteInfo.DEVICE_TYPE_REMOTE_SPEAKER instead.

A receiver device type of the route indicating the presentation of the media is happening on a speaker.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_REMOTE_SPEAKER

A receiver device type of the route indicating the presentation of the media is happening on a remote speaker.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_BLUETOOTH_A2DP

A receiver device type of the route indicating the presentation of the media is happening on a bluetooth device such as a bluetooth speaker.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_AUDIO_VIDEO_RECEIVER

A receiver device type indicating that the presentation of the media is happening on an Audio/Video receiver (AVR).

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_TABLET

A receiver device type indicating that the presentation of the media is happening on a tablet.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_TABLET_DOCKED

A receiver device type indicating that the presentation of the media is happening on a docked tablet.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_COMPUTER

A receiver device type indicating that the presentation of the media is happening on a computer.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_GAME_CONSOLE

A receiver device type indicating that the presentation of the media is happening on a gaming console.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_CAR

A receiver device type indicating that the presentation of the media is happening on a car.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_SMARTWATCH

A receiver device type indicating that the presentation of the media is happening on a smartwatch.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_SMARTPHONE

A receiver device type indicating that the presentation of the media is happening on a smartphone.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_BUILTIN_SPEAKER

A receiver device type indicating the presentation of the media is happening on a speaker system (i.e. a mono speaker or stereo speakers) built into the device.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_WIRED_HEADSET

A receiver device type indicating the presentation of the media is happening on a headset, which is the combination of a headphones and a microphone.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_WIRED_HEADPHONES

A receiver device type indicating the presentation of the media is happening on a pair of wired headphones.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_HDMI

A receiver device type indicating the presentation of the media is happening on an HDMI connection.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_USB_DEVICE

A receiver device type indicating the presentation of the media is happening on a USB audio device.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_USB_ACCESSORY

A receiver device type indicating the presentation of the media is happening on a USB audio device in accessory mode.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_DOCK

A receiver device type indicating the presentation of the media is happening on an audio device associated on a dock.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_USB_HEADSET

A receiver device type indicating the presentation of the media is happening on a USB audio headset.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_HEARING_AID

A receiver device type indicating the presentation of the media is happening on a hearing aid device.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_BLE_HEADSET

A receiver device type indicating the presentation of the media is happening on a Bluetooth Low Energy (BLE) HEADSET.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_HDMI_ARC

A receiver device type indicating the presentation of the media is happening on an Audio Return Channel of an HDMI connection

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_HDMI_EARC

A receiver device type indicating the presentation of the media is happening on an Enhanced Audio Return Channel of an HDMI connection

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int DEVICE_TYPE_GROUP

A receiver device type indicating that the presentation of the media is happening on a group of devices.

See also: MediaRouter.RouteInfo.getDeviceType()

public static final int PLAYBACK_VOLUME_FIXED

Playback information indicating the playback volume is fixed, i.e. it cannot be controlled from this object. An example of fixed playback volume is a remote player, playing over HDMI where the user prefers to control the volume on the HDMI sink, rather than attenuate at the source.

See also: MediaRouter.RouteInfo.getVolumeHandling()

public static final int PLAYBACK_VOLUME_VARIABLE

Playback information indicating the playback volume is variable and can be controlled from this object.

See also: MediaRouter.RouteInfo.getVolumeHandling()

public static final int PRESENTATION_DISPLAY_ID_NONE

The default presentation display id indicating no presentation display is associated with the route.

Methods

public MediaRouter.ProviderInfo getProvider()

Gets information about the provider of this media route.

public java.lang.String getId()

Gets the unique id of the route.

The route unique id functions as a stable identifier by which the route is known. For example, an application can use this id as a token to remember the selected route across restarts or to communicate its identity to a service.

Returns:

The unique id of the route, never null.

public java.lang.String getName()

Gets the user-visible name of the route.

The route name identifies the destination represented by the route. It may be a user-supplied name, an alias, or device serial number.

Returns:

The user-visible name of a media route. This is the string presented to users who may select this as the active route.

public java.lang.String getDescription()

Gets the user-visible description of the route.

The route description describes the kind of destination represented by the route. It may be a user-supplied string, a model number or brand of device.

Returns:

The description of the route, or null if none.

public Uri getIconUri()

Gets the URI of the icon representing this route.

This icon will be used in picker UIs if available.

Returns:

The URI of the icon representing this route, or null if none.

public boolean isEnabled()

Returns true if this route is enabled and may be selected.

Returns:

True if this route is enabled.

public boolean isSystemRoute()

Returns true if this route is a system route.

System routes are routes controlled by the system, like the device's built-in speakers, wired headsets, and bluetooth devices.

To use system routes, your application should write media sample data to a media framework API, typically via ExoPlayer.

public boolean isConnecting()

Deprecated: use MediaRouter.RouteInfo.getConnectionState() instead.

Returns true if the route is in the process of connecting and is not yet ready for use.

Returns:

True if this route is in the process of connecting.

public int getConnectionState()

Gets the connection state of the route.

Returns:

The connection state of this route: MediaRouter.RouteInfo.CONNECTION_STATE_DISCONNECTED, MediaRouter.RouteInfo.CONNECTION_STATE_CONNECTING, or MediaRouter.RouteInfo.CONNECTION_STATE_CONNECTED.

public boolean isSelected()

Returns true if this route is currently selected.

Must be called on the main thread.

Returns:

True if this route is currently selected.

See also: MediaRouter.getSelectedRoute()

public boolean isDefault()

Returns true if this route is the default route.

Must be called on the main thread.

Returns:

True if this route is the default route.

See also: MediaRouter.getDefaultRoute()

public boolean isBluetooth()

Returns true if this route is a bluetooth route.

Must be called on the main thread.

Returns:

True if this route is a bluetooth route.

See also: MediaRouter.getBluetoothRoute()

public boolean isDeviceSpeaker()

Returns true if this route is the default route and the device speaker.

Returns:

True if this route is the default route and the device speaker.

public java.util.List<IntentFilter> getControlFilters()

Gets a list of media control intent filters that describe the capabilities of this route and the media control actions that it supports.

Returns:

A list of intent filters that specifies the media control intents that this route supports.

See also: MediaControlIntent, MediaRouter.RouteInfo.supportsControlCategory(String), MediaRouter.RouteInfo.supportsControlRequest(Intent)

public boolean matchesSelector(MediaRouteSelector selector)

Returns true if the route supports at least one of the capabilities described by a media route selector.

Must be called on the main thread.

Parameters:

selector: The selector that specifies the capabilities to check.

Returns:

True if the route supports at least one of the capabilities described in the media route selector.

public boolean supportsControlCategory(java.lang.String category)

Returns true if the route supports the specified media control category.

Media control categories describe the capabilities of this route such as whether it supports live audio streaming or remote playback.

Must be called on the main thread.

Parameters:

category: A media control category such as MediaControlIntent.CATEGORY_LIVE_AUDIO, MediaControlIntent.CATEGORY_LIVE_VIDEO, MediaControlIntent.CATEGORY_REMOTE_PLAYBACK, or a provider-defined media control category.

Returns:

True if the route supports the specified intent category.

See also: MediaControlIntent, MediaRouter.RouteInfo.getControlFilters()

public boolean supportsControlAction(java.lang.String category, java.lang.String action)

Returns true if the route supports the specified media control category and action.

Media control actions describe specific requests that an application can ask a route to perform.

Must be called on the main thread.

Parameters:

category: A media control category such as MediaControlIntent.CATEGORY_LIVE_AUDIO, MediaControlIntent.CATEGORY_LIVE_VIDEO, MediaControlIntent.CATEGORY_REMOTE_PLAYBACK, or a provider-defined media control category.
action: A media control action such as MediaControlIntent.ACTION_PLAY.

Returns:

True if the route supports the specified intent action.

See also: MediaControlIntent, MediaRouter.RouteInfo.getControlFilters()

public boolean supportsControlRequest(Intent intent)

Returns true if the route supports the specified media control request.

Media control requests are used to request the route to perform actions such as starting remote playback of a media item.

Must be called on the main thread.

Parameters:

intent: A media control intent.

Returns:

True if the route can handle the specified intent.

See also: MediaControlIntent, MediaRouter.RouteInfo.getControlFilters()

public void sendControlRequest(Intent intent, MediaRouter.ControlRequestCallback callback)

Sends a media control request to be performed asynchronously by the route's destination.

Media control requests are used to request the route to perform actions such as starting remote playback of a media item.

This function may only be called on a selected route. Control requests sent to unselected routes will fail.

Must be called on the main thread.

Parameters:

intent: A media control intent.
callback: A MediaRouter.ControlRequestCallback to invoke with the result of the request, or null if no result is required.

See also: MediaControlIntent

public int getPlaybackType()

Gets the type of playback associated with this route.

Returns:

The type of playback associated with this route: MediaRouter.RouteInfo.PLAYBACK_TYPE_LOCAL or MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE.

public int getPlaybackStream()

Gets the audio stream over which the playback associated with this route is performed.

Returns:

The stream over which the playback associated with this route is performed.

public int getDeviceType()

Gets the type of the receiver device associated with this route.

Returns:

The type of the receiver device associated with this route.

public boolean isDefaultOrBluetooth()

public int getVolumeHandling()

Gets information about how volume is handled on the route.

Returns:

How volume is handled on the route: MediaRouter.RouteInfo.PLAYBACK_VOLUME_FIXED or MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE.

public int getVolume()

Gets the current volume for this route. Depending on the route, this may only be valid if the route is currently selected.

Returns:

The volume at which the playback associated with this route is performed.

public int getVolumeMax()

Gets the maximum volume at which the playback associated with this route is performed.

Returns:

The maximum volume at which the playback associated with this route is performed.

public boolean canDisconnect()

Gets whether this route supports disconnecting without interrupting playback.

Returns:

True if this route can disconnect without stopping playback, false otherwise.

public void requestSetVolume(int volume)

Requests a volume change for this route asynchronously.

This function may only be called on a selected route. It will have no effect if the route is currently unselected.

Must be called on the main thread.

Parameters:

volume: The new volume value between 0 and MediaRouter.RouteInfo.getVolumeMax().

public void requestUpdateVolume(int delta)

Requests an incremental volume update for this route asynchronously.

This function may only be called on a selected route. It will have no effect if the route is currently unselected.

Must be called on the main thread.

Parameters:

delta: The delta to add to the current volume.

public Display getPresentationDisplay()

Gets the Display that should be used by the application to show a on an external display when this route is selected. Depending on the route, this may only be valid if the route is currently selected.

The preferred presentation display may change independently of the route being selected or unselected. For example, the presentation display of the default system route may change when an external HDMI display is connected or disconnected even though the route itself has not changed.

This method may return null if there is no external display associated with the route or if the display is not ready to show UI yet.

The application should listen for changes to the presentation display using the MediaRouter.Callback.onRoutePresentationDisplayChanged(MediaRouter, MediaRouter.RouteInfo) callback and show or dismiss its accordingly when the display becomes available or is removed.

This method only makes sense for live video routes.

Must be called on the main thread.

Returns:

The preferred presentation display to use when this route is selected or null if none.

See also: MediaControlIntent.CATEGORY_LIVE_VIDEO

public int getPresentationDisplayId()

Gets the route's presentation display id, or -1 if none.

public Bundle getExtras()

Gets a collection of extra properties about this route that were supplied by its media route provider, or null if none.

public IntentSender getSettingsIntent()

Gets an intent sender for launching a settings activity for this route.

public void select()

Selects this media route.

Must be called on the main thread.

public boolean isGroup()

Returns true if the route has one or more members

Gets the dynamic group state of the given route.

public java.util.List<MediaRouter.RouteInfo> getMemberRoutes()

Returns the routes in this group

Returns:

The list of the routes in this group

public MediaRouteProvider.DynamicGroupRouteController getDynamicGroupController()

public java.lang.String toString()

public MediaRouteProvider getProviderInstance()