# MediaRouteDescriptor

Artifact: [androidx.mediarouter:mediarouter](https://developer.android.com/jetpack/androidx/releases/mediarouter) [View Source](https://cs.android.com/search?q=file:androidx/mediarouter/media/MediaRouteDescriptor.java+class:androidx.mediarouter.media.MediaRouteDescriptor) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

*** ** * ** ***


```
class MediaRouteDescriptor
```

<br />

*** ** * ** ***

Describes the properties of a route.

Each route is uniquely identified by an opaque id string. This token may take any form as long as it is unique within the media route provider.

This object is immutable once created using a `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor.Builder` instance.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#asBundle()()` Converts this object to a bundle for serialization. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#canDisconnectAndKeepPlaying()()` Gets whether the route can be disconnected without stopping playback. |
| `java-static https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor?` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#fromBundle(android.os.Bundle)(bundle: https://developer.android.com/reference/android/os/Bundle.html?)` Creates an instance from a bundle. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getAllowedPackages()()` Gets the set of allowed packages which are able to see the route or an empty set if only the route provider's package is allowed to see this route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getConnectionState()()` Gets the connection state of the route. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/content/IntentFilter.html!>` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getControlFilters()()` Gets the route's `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaControlIntent` filters. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getDeduplicationIds()()` Gets the route's deduplication ids. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getDescription()()` Gets the user-visible description of the route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getDeviceType()()` Gets the type of the receiver device associated with this route. |
| `https://developer.android.com/reference/android/os/Bundle.html?` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getExtras()()` Gets a bundle of extras for this route descriptor. |
| `https://developer.android.com/reference/android/net/Uri.html?` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getIconUri()()` Gets the URI of the icon representing this route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getId()()` Gets the unique id of the route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getName()()` Gets the user-visible name of the route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getPlaybackStream()()` Gets the route's playback stream. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getPlaybackType()()` Gets the type of playback associated with this route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getPresentationDisplayId()()` Gets the route's presentation display id, or -1 if none. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!>` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getRequiredPermissions()()` Returns a list of permission sets - all the permissions in at least one of these sets must be be held by an app to see this route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getRoutingControllerId()()` Gets the `https://developer.android.com/reference/android/media/MediaRouter2.RoutingController.html#getId()` associated with this route descriptor. |
| `https://developer.android.com/reference/android/content/IntentSender.html?` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getSettingsActivity()()` Gets an `https://developer.android.com/reference/android/content/IntentSender.html` for starting a settings activity for this route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getVolume()()` Gets the route's current volume, or 0 if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getVolumeHandling()()` Gets information about how volume is handled on the route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getVolumeMax()()` Gets the route's maximum volume, or 0 if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[isConnecting](https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isConnecting())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getConnectionState()` instead <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isDynamicGroupRoute()()` Returns if this route is a dynamic group route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isEnabled()()` Gets whether the route is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isSystemRoute()()` Returns `true` if this route is a system route. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isValid()()` Returns true if the route descriptor has all of the required fields. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isVisibilityPublic()()` Gets whether the route visibility is public or not. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#toString()()` |

## Public functions

### asBundle

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun asBundle(): Bundle
```

Converts this object to a bundle for serialization.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html` | The contents of the object represented as a bundle. |

### canDisconnectAndKeepPlaying

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun canDisconnectAndKeepPlaying(): Boolean
```

Gets whether the route can be disconnected without stopping playback.

The route can normally be disconnected without stopping playback when the destination device on the route is connected to two or more source devices. The route provider should update the route immediately when the number of connected devices changes.

To specify that the route should disconnect without stopping use `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter#unselect(int)` with `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter#UNSELECT_REASON_DISCONNECTED()`.

### fromBundle

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
java-static fun fromBundle(bundle: Bundle?): MediaRouteDescriptor?
```

Creates an instance from a bundle.

| Parameters |
|---|---|
| `bundle: https://developer.android.com/reference/android/os/Bundle.html?` | The bundle, or null if none. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor?` | The new instance, or null if the bundle was null. |

### getAllowedPackages

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.6.0)

```
fun getAllowedPackages(): (Mutable)Set<String!>
```

Gets the set of allowed packages which are able to see the route or an empty set if only the route provider's package is allowed to see this route. This applies only when `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isVisibilityPublic()` returns `false`.

### getConnectionState

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getConnectionState(): Int
```

Gets the connection state of the route.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The connection state of this route: `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#CONNECTION_STATE_DISCONNECTED()`, `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#CONNECTION_STATE_CONNECTING()`, or `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#CONNECTION_STATE_CONNECTED()`. |

### getControlFilters

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getControlFilters(): (Mutable)List<IntentFilter!>
```

Gets the route's `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaControlIntent` filters.

### getDeduplicationIds

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.6.0)

```
fun getDeduplicationIds(): (Mutable)Set<String!>
```

Gets the route's deduplication ids.

Two routes are considered to come from the same receiver device if any of their respective deduplication ids match.

### getDescription

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getDescription(): String?
```

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.

### getDeviceType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getDeviceType(): Int
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type of the receiver device associated with this route. |

### getExtras

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getExtras(): Bundle?
```

Gets a bundle of extras for this route descriptor. The extras will be ignored by the media router but they may be used by applications.

### getIconUri

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getIconUri(): Uri?
```

Gets the URI of the icon representing this route.

This icon will be used in picker UIs if available.

### getId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getId(): String
```

Gets the unique id of the route.

The route id associated with a route descriptor functions as a stable identifier for the route and must be unique among all routes offered by the provider.

### getName

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getName(): String
```

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.

### getPlaybackStream

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getPlaybackStream(): Int
```

Gets the route's playback stream.

### getPlaybackType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getPlaybackType(): Int
```

Gets the type of playback associated with this route.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The type of playback associated with this route: `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#PLAYBACK_TYPE_LOCAL()` or `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#PLAYBACK_TYPE_REMOTE()`. |

### getPresentationDisplayId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getPresentationDisplayId(): Int
```

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

### getRequiredPermissions

Added in [1.9.0-rc01](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.9.0-rc01)

```
fun getRequiredPermissions(): (Mutable)List<(Mutable)Set<String!>!>
```

Returns a list of permission sets - all the permissions in at least one of these sets must be be held by an app to see this route.

### getRoutingControllerId

Added in [1.9.0-rc01](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.9.0-rc01)

```
fun getRoutingControllerId(): String?
```

Gets the `https://developer.android.com/reference/android/media/MediaRouter2.RoutingController.html#getId()` associated with this route descriptor.

The routing session id is useful for populating the `https://developer.android.com/reference/android/media/session/MediaSession.html#setPlaybackToRemote(android.media.VolumeProvider)``https://developer.android.com/reference/android/media/VolumeProvider.html#getVolumeControlId()`.

This value may be null if this descriptor is not representing a routing session from the `https://developer.android.com/reference/android/media/MediaRouter2.html` framework. Typically, this value will be available in descriptors from the `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter#getSelectedRoute()` when `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouterParams#isMediaTransferReceiverEnabled()` (which controls Android Output Switcher integration).

### getSettingsActivity

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getSettingsActivity(): IntentSender?
```

Gets an `https://developer.android.com/reference/android/content/IntentSender.html` for starting a settings activity for this route. The activity may have specific route settings or general settings for the connected device or route provider.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/content/IntentSender.html?` | An `https://developer.android.com/reference/android/content/IntentSender.html` to start a settings activity. |

### getVolume

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getVolume(): Int
```

Gets the route's current volume, or 0 if unknown.

### getVolumeHandling

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getVolumeHandling(): Int
```

Gets information about how volume is handled on the route.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | How volume is handled on the route: `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#PLAYBACK_VOLUME_FIXED()` or `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouter.RouteInfo#PLAYBACK_VOLUME_VARIABLE()`. |

### getVolumeMax

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun getVolumeMax(): Int
```

Gets the route's maximum volume, or 0 if unknown.

### isConnecting

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun [isConnecting](https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#isConnecting())(): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteDescriptor#getConnectionState()` instead

Gets whether the route is connecting.

### isDynamicGroupRoute

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun isDynamicGroupRoute(): Boolean
```

Returns if this route is a dynamic group route.

`https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteProvider` creates a dynamic group route when `https://developer.android.com/reference/kotlin/androidx/mediarouter/media/MediaRouteProvider#onCreateDynamicGroupRouteController(java.lang.String,androidx.mediarouter.media.MediaRouteProvider.RouteControllerOptions)` is called. It happens when a single route or a single static group is selected.

If a single device or a static group is selected, the associated dynamic group route should not be seen by any client app because there is already one for the device. After user added more devices into the session, it should be seen by the client app. The provider can treat this by not setting the media intent for the dynamic group route if it contains only one member.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if this route is a dynamic group route. |

### isEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun isEnabled(): Boolean
```

Gets whether the route is enabled.

### isSystemRoute

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.7.0)

```
fun isSystemRoute(): Boolean
```

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](https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer).

### isValid

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.1.0)

```
fun isValid(): Boolean
```

Returns true if the route descriptor has all of the required fields.

### isVisibilityPublic

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/mediarouter#1.6.0)

```
fun isVisibilityPublic(): Boolean
```

Gets whether the route visibility is public or not.

### toString

```
fun toString(): String
```