# MediaRouter

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:mediarouter-v7:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v7/media/MediaRouter#nestedclasses)\|[Constants](https://developer.android.com/reference/android/support/v7/media/MediaRouter#constants)\|[Methods](https://developer.android.com/reference/android/support/v7/media/MediaRouter#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/media/MediaRouter#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/media/MediaRouter#)  

# MediaRouter

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
MediaRouter
`  
`

extends Object


``


`

|---|--------------------------------------|
| java.lang.Object                        ||
| ↳ | android.support.v7.media.MediaRouter |

<br />

*** ** * ** ***

MediaRouter allows applications to control the routing of media channels and streams from the current device to external speakers and destination devices.

A MediaRouter instance is retrieved through[getInstance(Context)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getInstance(android.content.Context)). Applications can query the media router about the currently selected route and its capabilities to determine how to send content to the route's destination. Applications can also[send control requests](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo#sendControlRequest(android.content.Intent, android.support.v7.media.MediaRouter.ControlRequestCallback))to the route to ask the route's destination to perform certain remote control functions such as playing media.

See also[MediaRouteProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider)for information on how an application can publish new media routes to the media router.

The media router API is not thread-safe; all interactions with it must be done from the main thread of the process.

<br />

## Summary

|                                                                                                    ### Nested classes                                                                                                     ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [MediaRouter.Callback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback) Interface for receiving events about media routing changes.                                       |
| ` class` | [MediaRouter.ControlRequestCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ControlRequestCallback) Callback which is invoked with the result of a media control request. |
| ` class` | [MediaRouter.ProviderInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ProviderInfo) Provides information about a media route provider.                                        |
| ` class` | [MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo) Provides information about a media route.                                                       |

|                                                                                                                                                                                                                                                                                                           ### Constants                                                                                                                                                                                                                                                                                                            ||
|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE](https://developer.android.com/reference/android/support/v7/media/MediaRouter#AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE) Flag for[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int)): Ignore the default route.                                                                                                                                                                                                                               |
| `int` | [AVAILABILITY_FLAG_REQUIRE_MATCH](https://developer.android.com/reference/android/support/v7/media/MediaRouter#AVAILABILITY_FLAG_REQUIRE_MATCH) Flag for[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int)): Require an actual route to be matched.                                                                                                                                                                                                                                |
| `int` | [CALLBACK_FLAG_FORCE_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_FORCE_DISCOVERY) Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Request passive route discovery while this callback is registered, even on[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice()).                                  |
| `int` | [CALLBACK_FLAG_PERFORM_ACTIVE_SCAN](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_PERFORM_ACTIVE_SCAN) Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Actively scan for routes while this callback is registered.                                                                                                                                                      |
| `int` | [CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY) Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Request passive route discovery while this callback is registered, except on[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice()).                            |
| `int` | [CALLBACK_FLAG_UNFILTERED_EVENTS](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_UNFILTERED_EVENTS) Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Do not filter route events.                                                                                                                                                                                          |
| `int` | [UNSELECT_REASON_DISCONNECTED](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_DISCONNECTED) Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the user pressed the disconnect button to disconnect and keep playing. |
| `int` | [UNSELECT_REASON_ROUTE_CHANGED](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_ROUTE_CHANGED) Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the user selected a different route.                                 |
| `int` | [UNSELECT_REASON_STOPPED](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_STOPPED) Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the user pressed the stop casting button.                                        |
| `int` | [UNSELECT_REASON_UNKNOWN](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_UNKNOWN) Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the reason the route was unselected is unknown.                                  |

|                                                                                                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                                                                                                  ||
|----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                                                                          | ` `[addCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback, int))`(`[MediaRouteSelector](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector)` selector, `[MediaRouter.Callback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback)` callback, int flags) ` Registers a callback to discover routes that match the selector and to receive events when they change. |
| ` void`                                                                                                                          | ` `[addCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback))`(`[MediaRouteSelector](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector)` selector, `[MediaRouter.Callback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback)` callback) ` Registers a callback to discover routes that match the selector and to receive events when they change.                 |
| ` void`                                                                                                                          | ` `[addProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addProvider(android.support.v7.media.MediaRouteProvider))`(`[MediaRouteProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider)` providerInstance) ` Registers a media route provider within this application process.                                                                                                                                                                                                                        |
| ` void`                                                                                                                          | ` `[addRemoteControlClient](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addRemoteControlClient(java.lang.Object))`(Object remoteControlClient) ` Adds a remote control client to enable remote control of the volume of the selected route.                                                                                                                                                                                                                                                                                                      |
| ` `[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)               | ` `[getBluetoothRoute](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getBluetoothRoute())`() ` Gets a bluetooth route for playing media content on the system.                                                                                                                                                                                                                                                                                                                                                                                     |
| ` `[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)               | ` `[getDefaultRoute](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getDefaultRoute())`() ` Gets the default route for playing media content on the system.                                                                                                                                                                                                                                                                                                                                                                                         |
| ` static `[MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter)                            | ` `[getInstance](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getInstance(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context.html)` context) ` Gets an instance of the media router service associated with the context.                                                                                                                                                                                                                                                                       |
| ` `[MediaSessionCompat.Token](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Token) | ` `[getMediaSessionToken](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getMediaSessionToken())`() `                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ` List<`[MediaRouter.ProviderInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ProviderInfo)`>` | ` `[getProviders](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getProviders())`() ` Gets information about the[route providers](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ProviderInfo)currently known to this media router.                                                                                                                                                                                                                                                                                   |
| ` List<`[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)`>`       | ` `[getRoutes](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getRoutes())`() ` Gets information about the[routes](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)currently known to this media router.                                                                                                                                                                                                                                                                                                     |
| ` `[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)               | ` `[getSelectedRoute](https://developer.android.com/reference/android/support/v7/media/MediaRouter#getSelectedRoute())`() ` Gets the currently selected route.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` boolean`                                                                                                                       | ` `[isRouteAvailable](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int))`(`[MediaRouteSelector](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector)` selector, int flags) ` Returns true if there is a route that matches the specified selector.                                                                                                                                                                                                  |
| ` void`                                                                                                                          | ` `[removeCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter#removeCallback(android.support.v7.media.MediaRouter.Callback))`(`[MediaRouter.Callback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback)` callback) ` Removes the specified callback.                                                                                                                                                                                                                                                      |
| ` void`                                                                                                                          | ` `[removeProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouter#removeProvider(android.support.v7.media.MediaRouteProvider))`(`[MediaRouteProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider)` providerInstance) ` Unregisters a media route provider within this application process.                                                                                                                                                                                                                |
| ` void`                                                                                                                          | ` `[removeRemoteControlClient](https://developer.android.com/reference/android/support/v7/media/MediaRouter#removeRemoteControlClient(java.lang.Object))`(Object remoteControlClient) ` Removes a remote control client.                                                                                                                                                                                                                                                                                                                                                          |
| ` void`                                                                                                                          | ` `[selectRoute](https://developer.android.com/reference/android/support/v7/media/MediaRouter#selectRoute(android.support.v7.media.MediaRouter.RouteInfo))`(`[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)` route) ` Selects the specified route.                                                                                                                                                                                                                                                               |
| ` void`                                                                                                                          | ` `[setMediaSession](https://developer.android.com/reference/android/support/v7/media/MediaRouter#setMediaSession(java.lang.Object))`(Object mediaSession) ` Sets the media session to enable remote control of the volume of the selected route.                                                                                                                                                                                                                                                                                                                                 |
| ` void`                                                                                                                          | ` `[setMediaSessionCompat](https://developer.android.com/reference/android/support/v7/media/MediaRouter#setMediaSessionCompat(android.support.v4.media.session.MediaSessionCompat))`(`[MediaSessionCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat)` mediaSession) ` Sets a compat media session to enable remote control of the volume of the selected route.                                                                                                                                                                |
| ` void`                                                                                                                          | ` `[unselect](https://developer.android.com/reference/android/support/v7/media/MediaRouter#unselect(int))`(int reason) ` Unselects the current round and selects the default route instead.                                                                                                                                                                                                                                                                                                                                                                                       |
| ` `[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)               | ` `[updateSelectedRoute](https://developer.android.com/reference/android/support/v7/media/MediaRouter#updateSelectedRoute(android.support.v7.media.MediaRouteSelector))`(`[MediaRouteSelector](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector)` selector) ` Returns the selected route if it matches the specified selector, otherwise selects the default route and returns it.                                                                                                                                                             |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE
```

Flag for[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int)): Ignore the default route.

This flag is used to determine whether a matching non-default route is available. This constraint may be used to decide whether to offer the route chooser dialog to the user. There is no point offering the chooser if there are no non-default choices.

<br />

<br />

Constant Value: 1 (0x00000001)  

### AVAILABILITY_FLAG_REQUIRE_MATCH

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int AVAILABILITY_FLAG_REQUIRE_MATCH
```

Flag for[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int)): Require an actual route to be matched.

If this flag is not set, then[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int))will return true if it is possible to discover a matching route even if discovery is not in progress or if no matching route has yet been found. This feature is used to save resources by removing the need to perform passive route discovery on[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice()).

If this flag is set, then[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int))will only return true if a matching route has actually been discovered.

<br />

<br />

Constant Value: 2 (0x00000002)  

### CALLBACK_FLAG_FORCE_DISCOVERY

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int CALLBACK_FLAG_FORCE_DISCOVERY
```

Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Request passive route discovery while this callback is registered, even on[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice()).

This flag has a significant performance impact on low-RAM devices since it may cause many media route providers to be started simultaneously. It is much better to use[CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY)instead to avoid performing passive discovery on these devices altogether. Refer to[addCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback, int))for details.

<br />

<br />

**See also:**

- [MediaRouteDiscoveryFragment](https://developer.android.com/reference/android/support/v7/app/MediaRouteDiscoveryFragment)

Constant Value: 8 (0x00000008)  

### CALLBACK_FLAG_PERFORM_ACTIVE_SCAN

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int CALLBACK_FLAG_PERFORM_ACTIVE_SCAN
```

Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Actively scan for routes while this callback is registered.

When this flag is specified, the media router will actively scan for new routes. Certain routes, such as wifi display routes, may not be discoverable except when actively scanning. This flag is typically used when the route picker dialog has been opened by the user to ensure that the route information is up to date.

Active scanning may consume a significant amount of power and may have intrusive effects on wireless connectivity. Therefore it is important that active scanning only be requested when it is actually needed to satisfy a user request to discover and select a new route.

This flag implies[CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY)but performing active scans is much more expensive than a normal discovery request.

<br />

<br />

**See also:**

- [CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY)

Constant Value: 1 (0x00000001)  

### CALLBACK_FLAG_REQUEST_DISCOVERY

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int CALLBACK_FLAG_REQUEST_DISCOVERY
```

Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Request passive route discovery while this callback is registered, except on[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice()).

When this flag is specified, the media router will try to discover routes. Although route discovery is intended to be efficient, checking for new routes may result in some network activity and could slowly drain the battery. Therefore applications should only specify[CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY)when they are running in the foreground and would like to provide the user with the option of connecting to new routes.

Applications should typically add a callback using this flag in the[activity's](https://developer.android.com/reference/android/app/Activity.html)[onStart](https://developer.android.com/reference/android/app/Activity.html#onStart())method and remove it in the[onStop](https://developer.android.com/reference/android/app/Activity.html#onStop())method. The[MediaRouteDiscoveryFragment](https://developer.android.com/reference/android/support/v7/app/MediaRouteDiscoveryFragment)fragment may also be used for this purpose.

On[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice())this flag will be ignored. Refer to[addCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback, int))for details.

<br />

<br />

**See also:**

- [MediaRouteDiscoveryFragment](https://developer.android.com/reference/android/support/v7/app/MediaRouteDiscoveryFragment)

Constant Value: 4 (0x00000004)  

### CALLBACK_FLAG_UNFILTERED_EVENTS

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int CALLBACK_FLAG_UNFILTERED_EVENTS
```

Flag for[addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback)): Do not filter route events.

When this flag is specified, the callback will be invoked for events that affect any route even if they do not match the callback's filter.

<br />

<br />

Constant Value: 2 (0x00000002)  

### UNSELECT_REASON_DISCONNECTED

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int UNSELECT_REASON_DISCONNECTED
```

Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the user pressed the disconnect button to disconnect and keep playing.

<br />

<br />

**See also:**

- [canDisconnectAndKeepPlaying()](https://developer.android.com/reference/android/support/v7/media/MediaRouteDescriptor#canDisconnectAndKeepPlaying())

Constant Value: 1 (0x00000001)  

### UNSELECT_REASON_ROUTE_CHANGED

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int UNSELECT_REASON_ROUTE_CHANGED
```

Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the user selected a different route.

<br />

Constant Value: 3 (0x00000003)  

### UNSELECT_REASON_STOPPED

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int UNSELECT_REASON_STOPPED
```

Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the user pressed the stop casting button.

<br />

Constant Value: 2 (0x00000002)  

### UNSELECT_REASON_UNKNOWN

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int UNSELECT_REASON_UNKNOWN
```

Passed to[onUnselect(int)](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController#onUnselect(int))and[onRouteUnselected(MediaRouter, RouteInfo, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback#onRouteUnselected(android.support.v7.media.MediaRouter, android.support.v7.media.MediaRouter.RouteInfo, int))when the reason the route was unselected is unknown.

<br />

Constant Value: 0 (0x00000000)

## Public methods

### addCallback

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void addCallback (MediaRouteSelector selector, 
                MediaRouter.Callback callback, 
                int flags)
```

Registers a callback to discover routes that match the selector and to receive events when they change.

The selector describes the kinds of routes that the application wants to discover. For example, if the application wants to use live audio routes then it should include the[live audio media control intent category](https://developer.android.com/reference/android/support/v7/media/MediaControlIntent#CATEGORY_LIVE_AUDIO)in its selector when it adds a callback to the media router. The selector may include any number of categories.

If the callback has already been registered, then the selector is added to the set of selectors being monitored by the callback.

By default, the callback will only be invoked for events that affect routes that match the specified selector. Event filtering may be disabled by specifying the[CALLBACK_FLAG_UNFILTERED_EVENTS](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_UNFILTERED_EVENTS)flag when the callback is registered.

Applications should use the[isRouteAvailable(MediaRouteSelector, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#isRouteAvailable(android.support.v7.media.MediaRouteSelector, int))method to determine whether is it possible to discover a route with the desired capabilities and therefore whether the media route button should be shown to the user.

The[CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY)flag should be used while the application is in the foreground to request that passive discovery be performed if there are sufficient resources to allow continuous passive discovery. On[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice())this flag will be ignored to conserve resources.

The[CALLBACK_FLAG_FORCE_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_FORCE_DISCOVERY)flag should be used when passive discovery absolutely must be performed, even on low-RAM devices. This flag has a significant performance impact on low-RAM devices since it may cause many media route providers to be started simultaneously. It is much better to use[CALLBACK_FLAG_REQUEST_DISCOVERY](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_REQUEST_DISCOVERY)instead to avoid performing passive discovery on these devices altogether.

The[CALLBACK_FLAG_PERFORM_ACTIVE_SCAN](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_PERFORM_ACTIVE_SCAN)flag should be used when the media route chooser dialog is showing to confirm the presence of available routes that the user may connect to. This flag may use substantially more power.

### Example

```
 public class MyActivity extends Activity {
     private MediaRouter mRouter;
     private MediaRouter.Callback mCallback;
     private MediaRouteSelector mSelector;

     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         mRouter = Mediarouter.getInstance(this);
         mCallback = new MyCallback();
         mSelector = new MediaRouteSelector.Builder()
                 .addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
                 .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
                 .build();
     }

     // Add the callback on start to tell the media router what kinds of routes
     // the application is interested in so that it can try to discover suitable ones.
     public void onStart() {
         super.onStart();

         mediaRouter.addCallback(mSelector, mCallback,
                 MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);

         MediaRouter.RouteInfo route = mediaRouter.updateSelectedRoute(mSelector);
         // do something with the route...
     }

     // Remove the selector on stop to tell the media router that it no longer
     // needs to invest effort trying to discover routes of these kinds for now.
     public void onStop() {
         super.onStop();

         mediaRouter.removeCallback(mCallback);
     }

     private final class MyCallback extends MediaRouter.Callback {
         // Implement callback methods as needed.
     }
 }
 
```

<br />

<br />

|                                                                                                                                                                                                   Parameters                                                                                                                                                                                                   ||
|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `selector` | `MediaRouteSelector`: A route selector that indicates the kinds of routes that the callback would like to discover. <br />                                                                                                                                                                                                                                                                         |
| `callback` | `MediaRouter.Callback`: The callback to add. <br />                                                                                                                                                                                                                                                                                                                                                |
| `flags`    | `int`: Flags to control the behavior of the callback. May be zero or a combination of[CALLBACK_FLAG_PERFORM_ACTIVE_SCAN](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_PERFORM_ACTIVE_SCAN)and[CALLBACK_FLAG_UNFILTERED_EVENTS](https://developer.android.com/reference/android/support/v7/media/MediaRouter#CALLBACK_FLAG_UNFILTERED_EVENTS). <br /> |

**See also:**

- [removeCallback(MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#removeCallback(android.support.v7.media.MediaRouter.Callback))  

### addCallback

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void addCallback (MediaRouteSelector selector, 
                MediaRouter.Callback callback)
```

Registers a callback to discover routes that match the selector and to receive events when they change.

This is a convenience method that has the same effect as calling[addCallback(MediaRouteSelector, Callback, int)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback, int))without flags.

<br />

<br />

|                                                               Parameters                                                               ||
|------------|----------------------------------------------------------------------------------------------------------------------------|
| `selector` | `MediaRouteSelector`: A route selector that indicates the kinds of routes that the callback would like to discover. <br /> |
| `callback` | `MediaRouter.Callback`: The callback to add. <br />                                                                        |

**See also:**

- [removeCallback(MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#removeCallback(android.support.v7.media.MediaRouter.Callback))  

### addProvider

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void addProvider (MediaRouteProvider providerInstance)
```

Registers a media route provider within this application process.

The provider will be added to the list of providers that all[MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter)instances within this process can use to discover routes.

<br />

<br />

|                                         Parameters                                         ||
|--------------------|------------------------------------------------------------------------|
| `providerInstance` | `MediaRouteProvider`: The media route provider instance to add. <br /> |

**See also:**

- [MediaRouteProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider)
- [removeCallback(MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#removeCallback(android.support.v7.media.MediaRouter.Callback))  

### addRemoteControlClient

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void addRemoteControlClient (Object remoteControlClient)
```

Adds a remote control client to enable remote control of the volume of the selected route.

The remote control client must have previously been registered with the audio manager using the[AudioManager.registerRemoteControlClient](https://developer.android.com/reference/android/media/AudioManager.html#registerRemoteControlClient(android.media.RemoteControlClient))method.

<br />

<br />

|                                                                          Parameters                                                                          ||
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `remoteControlClient` | `Object`: The[RemoteControlClient](https://developer.android.com/reference/android/media/RemoteControlClient.html)to register. <br /> |

### getBluetoothRoute

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaRouter.RouteInfo getBluetoothRoute ()
```

Gets a bluetooth route for playing media content on the system.

<br />

|                                                                               Returns                                                                                ||
|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| [MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo) | A bluetooth route, if exist, otherwise null. <br /> |

### getDefaultRoute

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaRouter.RouteInfo getDefaultRoute ()
```

Gets the default route for playing media content on the system.

The system always provides a default route.

<br />

<br />

|                                                                                     Returns                                                                                      ||
|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo) | The default route, which is guaranteed to never be null. <br /> |

### getInstance

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaRouter getInstance (Context context)
```

Gets an instance of the media router service associated with the context.

The application is responsible for holding a strong reference to the returned[MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter)instance, such as by storing the instance in a field of the[Activity](https://developer.android.com/reference/android/app/Activity.html), to ensure that the media router remains alive as long as the application is using its features.

In other words, the support library only holds a[weak reference](https://developer.android.com/reference/java/lang/ref/WeakReference)to each media router instance. When there are no remaining strong references to the media router instance, all of its callbacks will be removed and route discovery will no longer be performed on its behalf.

<br />

<br />

|         Parameters          ||
|-----------|------------------|
| `context` | `Context` <br /> |

|                                                                                                               Returns                                                                                                               ||
|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter) | The media router instance for the context. The application must hold a strong reference to this object as long as it is in use. <br /> |

### getMediaSessionToken

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaSessionCompat.Token getMediaSessionToken ()
```

<br />

<br />

|                                                                Returns                                                                ||
|-------------------------------------------------------------------------------------------------------------------------------|--------|
| [MediaSessionCompat.Token](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat.Token) | <br /> |

### getProviders

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
List<MediaRouter.ProviderInfo> getProviders ()
```

Gets information about the[route providers](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ProviderInfo)currently known to this media router.

<br />

|                                                                 Returns                                                                 ||
|---------------------------------------------------------------------------------------------------------------------------------|--------|
| `List<`[MediaRouter.ProviderInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ProviderInfo)`>` | <br /> |

### getRoutes

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
List<MediaRouter.RouteInfo> getRoutes ()
```

Gets information about the[routes](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)currently known to this media router.

<br />

|                                                              Returns                                                              ||
|---------------------------------------------------------------------------------------------------------------------------|--------|
| `List<`[MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)`>` | <br /> |

### getSelectedRoute

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaRouter.RouteInfo getSelectedRoute ()
```

Gets the currently selected route.

The application should examine the route's[media control intent filters](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo#getControlFilters())to assess the capabilities of the route before attempting to use it.

### Example

```
 public boolean playMovie() {
     MediaRouter mediaRouter = MediaRouter.getInstance(context);
     MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute();

     // First try using the remote playback interface, if supported.
     if (route.supportsControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)) {
         // The route supports remote playback.
         // Try to send it the Uri of the movie to play.
         Intent intent = new Intent(MediaControlIntent.ACTION_PLAY);
         intent.addCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK);
         intent.setDataAndType("http://example.com/videos/movie.mp4", "video/mp4");
         if (route.supportsControlRequest(intent)) {
             route.sendControlRequest(intent, null);
             return true; // sent the request to play the movie
         }
     }

     // If remote playback was not possible, then play locally.
     if (route.supportsControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)) {
         // The route supports live video streaming.
         // Prepare to play content locally in a window or in a presentation.
         return playMovieInWindow();
     }

     // Neither interface is supported, so we can't play the movie to this route.
     return false;
 }
 
```

<br />

<br />

|                                                                                      Returns                                                                                      ||
|-----------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| [MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo) | The selected route, which is guaranteed to never be null. <br /> |

**See also:**

- [getControlFilters()](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo#getControlFilters())
- [supportsControlCategory(String)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo#supportsControlCategory(java.lang.String))
- [supportsControlRequest(Intent)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo#supportsControlRequest(android.content.Intent))  

### isRouteAvailable

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean isRouteAvailable (MediaRouteSelector selector, 
                int flags)
```

Returns true if there is a route that matches the specified selector.

This method returns true if there are any available routes that match the selector regardless of whether they are enabled or disabled. If the[AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE](https://developer.android.com/reference/android/support/v7/media/MediaRouter#AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE)flag is specified, then the method will only consider non-default routes.

On[low-RAM devices](https://developer.android.com/reference/android/app/ActivityManager.html#isLowRamDevice())this method will return true if it is possible to discover a matching route even if discovery is not in progress or if no matching route has yet been found. Use[AVAILABILITY_FLAG_REQUIRE_MATCH](https://developer.android.com/reference/android/support/v7/media/MediaRouter#AVAILABILITY_FLAG_REQUIRE_MATCH)to require an actual match.

<br />

<br />

|                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                      ||
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `selector` | `MediaRouteSelector`: The selector to match. <br />                                                                                                                                                                                                                                                                                                                                                                                      |
| `flags`    | `int`: Flags to control the determination of whether a route may be available. May be zero or some combination of[AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE](https://developer.android.com/reference/android/support/v7/media/MediaRouter#AVAILABILITY_FLAG_IGNORE_DEFAULT_ROUTE)and[AVAILABILITY_FLAG_REQUIRE_MATCH](https://developer.android.com/reference/android/support/v7/media/MediaRouter#AVAILABILITY_FLAG_REQUIRE_MATCH). <br /> |

|                           Returns                            ||
|-----------|---------------------------------------------------|
| `boolean` | True if a matching route may be available. <br /> |

### removeCallback

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void removeCallback (MediaRouter.Callback callback)
```

Removes the specified callback. It will no longer receive events about changes to media routes.

<br />

|                             Parameters                             ||
|------------|--------------------------------------------------------|
| `callback` | `MediaRouter.Callback`: The callback to remove. <br /> |

**See also:**

- [addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback))  

### removeProvider

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void removeProvider (MediaRouteProvider providerInstance)
```

Unregisters a media route provider within this application process.

The provider will be removed from the list of providers that all[MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter)instances within this process can use to discover routes.

<br />

<br />

|                                          Parameters                                           ||
|--------------------|---------------------------------------------------------------------------|
| `providerInstance` | `MediaRouteProvider`: The media route provider instance to remove. <br /> |

**See also:**

- [MediaRouteProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider)
- [addCallback(MediaRouteSelector, MediaRouter.Callback)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addCallback(android.support.v7.media.MediaRouteSelector, android.support.v7.media.MediaRouter.Callback))  

### removeRemoteControlClient

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void removeRemoteControlClient (Object remoteControlClient)
```

Removes a remote control client.

<br />

|                                                                           Parameters                                                                           ||
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `remoteControlClient` | `Object`: The[RemoteControlClient](https://developer.android.com/reference/android/media/RemoteControlClient.html)to unregister. <br /> |

### selectRoute

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void selectRoute (MediaRouter.RouteInfo route)
```

Selects the specified route.

<br />

|                          Parameters                           ||
|---------|------------------------------------------------------|
| `route` | `MediaRouter.RouteInfo`: The route to select. <br /> |

### setMediaSession

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setMediaSession (Object mediaSession)
```

Sets the media session to enable remote control of the volume of the selected route. This should be used instead of[addRemoteControlClient(Object)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addRemoteControlClient(java.lang.Object))when using media sessions. Set the session to null to clear it.

<br />

|                                                                 Parameters                                                                 ||
|----------------|----------------------------------------------------------------------------------------------------------------------------|
| `mediaSession` | `Object`: The[MediaSession](https://developer.android.com/reference/android/media/session/MediaSession.html)to use. <br /> |

### setMediaSessionCompat

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setMediaSessionCompat (MediaSessionCompat mediaSession)
```

Sets a compat media session to enable remote control of the volume of the selected route. This should be used instead of[addRemoteControlClient(Object)](https://developer.android.com/reference/android/support/v7/media/MediaRouter#addRemoteControlClient(java.lang.Object))when using[MediaSessionCompat](https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat). Set the session to null to clear it.

<br />

### unselect

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void unselect (int reason)
```

Unselects the current round and selects the default route instead.

The reason given must be one of:

- [UNSELECT_REASON_UNKNOWN](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_UNKNOWN)
- [UNSELECT_REASON_DISCONNECTED](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_DISCONNECTED)
- [UNSELECT_REASON_STOPPED](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_STOPPED)
- [UNSELECT_REASON_ROUTE_CHANGED](https://developer.android.com/reference/android/support/v7/media/MediaRouter#UNSELECT_REASON_ROUTE_CHANGED)

<br />

<br />

|                               Parameters                                ||
|----------|---------------------------------------------------------------|
| `reason` | `int`: The reason for disconnecting the current route. <br /> |

### updateSelectedRoute

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
MediaRouter.RouteInfo updateSelectedRoute (MediaRouteSelector selector)
```

Returns the selected route if it matches the specified selector, otherwise selects the default route and returns it. If there is one live audio route (usually Bluetooth A2DP), it will be selected instead of default route.

<br />

|                           Parameters                            ||
|------------|-----------------------------------------------------|
| `selector` | `MediaRouteSelector`: The selector to match. <br /> |

|                                                                                                                              Returns                                                                                                                               ||
|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo) | The previously selected route if it matched the selector, otherwise the newly selected default route which is guaranteed to never be null. <br /> |

**See also:**

- [MediaRouteSelector](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector)
- [matchesSelector(MediaRouteSelector)](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo#matchesSelector(android.support.v7.media.MediaRouteSelector))  
-

  ## Interfaces

  - [RemotePlaybackClient.OnMessageReceivedListener](https://developer.android.com/reference/android/support/v7/media/RemotePlaybackClient.OnMessageReceivedListener)
-

  ## Classes

  - [MediaControlIntent](https://developer.android.com/reference/android/support/v7/media/MediaControlIntent)
  - [MediaItemMetadata](https://developer.android.com/reference/android/support/v7/media/MediaItemMetadata)
  - [MediaItemStatus](https://developer.android.com/reference/android/support/v7/media/MediaItemStatus)
  - [MediaItemStatus.Builder](https://developer.android.com/reference/android/support/v7/media/MediaItemStatus.Builder)
  - [MediaRouteDescriptor](https://developer.android.com/reference/android/support/v7/media/MediaRouteDescriptor)
  - [MediaRouteDescriptor.Builder](https://developer.android.com/reference/android/support/v7/media/MediaRouteDescriptor.Builder)
  - [MediaRouteDiscoveryRequest](https://developer.android.com/reference/android/support/v7/media/MediaRouteDiscoveryRequest)
  - [MediaRouteProvider](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider)
  - [MediaRouteProvider.Callback](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.Callback)
  - [MediaRouteProvider.ProviderMetadata](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.ProviderMetadata)
  - [MediaRouteProvider.RouteController](https://developer.android.com/reference/android/support/v7/media/MediaRouteProvider.RouteController)
  - [MediaRouteProviderDescriptor](https://developer.android.com/reference/android/support/v7/media/MediaRouteProviderDescriptor)
  - [MediaRouteProviderDescriptor.Builder](https://developer.android.com/reference/android/support/v7/media/MediaRouteProviderDescriptor.Builder)
  - [MediaRouteProviderService](https://developer.android.com/reference/android/support/v7/media/MediaRouteProviderService)
  - [MediaRouter](https://developer.android.com/reference/android/support/v7/media/MediaRouter)
  - [MediaRouter.Callback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.Callback)
  - [MediaRouter.ControlRequestCallback](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ControlRequestCallback)
  - [MediaRouter.ProviderInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.ProviderInfo)
  - [MediaRouter.RouteInfo](https://developer.android.com/reference/android/support/v7/media/MediaRouter.RouteInfo)
  - [MediaRouteSelector](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector)
  - [MediaRouteSelector.Builder](https://developer.android.com/reference/android/support/v7/media/MediaRouteSelector.Builder)
  - [MediaSessionStatus](https://developer.android.com/reference/android/support/v7/media/MediaSessionStatus)
  - [MediaSessionStatus.Builder](https://developer.android.com/reference/android/support/v7/media/MediaSessionStatus.Builder)
  - [RemotePlaybackClient](https://developer.android.com/reference/android/support/v7/media/RemotePlaybackClient)
  - [RemotePlaybackClient.ActionCallback](https://developer.android.com/reference/android/support/v7/media/RemotePlaybackClient.ActionCallback)
  - [RemotePlaybackClient.ItemActionCallback](https://developer.android.com/reference/android/support/v7/media/RemotePlaybackClient.ItemActionCallback)
  - [RemotePlaybackClient.SessionActionCallback](https://developer.android.com/reference/android/support/v7/media/RemotePlaybackClient.SessionActionCallback)
  - [RemotePlaybackClient.StatusCallback](https://developer.android.com/reference/android/support/v7/media/RemotePlaybackClient.StatusCallback)