# MediaRoute2Info.Builder

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/MediaRoute2Info.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                 ||
| ↳ | [android.media.MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) |

Builder for[media route info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info).

## Summary

|                                                                                                                                                                                                                                                Public constructors                                                                                                                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#Builder(android.media.MediaRoute2Info))`(`routeInfo:` `[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)`)` Constructor for builder to create[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)with existing[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)instance. |
| [Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#Builder(kotlin.String,%20kotlin.CharSequence))`(`id:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `name:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`)` Constructor for builder to create[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info).                           |

|                                                                                                                                                                                                                                                                                                                                         Public methods                                                                                                                                                                                                                                                                                                                                          ||
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [addFeature](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#addFeature(kotlin.String))`(`feature:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Adds a feature for the route.                                                                                                                                                                                                                                                                                                                   |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [addFeatures](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#addFeatures(kotlin.collections.MutableCollection))`(`features:` `[MutableCollection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>`)` Adds features for the route.                                                                                                                                                                    |
| [MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)                  | [build](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#build())`()` Builds the[media route info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info).                                                                                                                                                                                                                                                                                                                                                         |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [clearFeatures](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#clearFeatures())`()` Clears the features of the route.                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setClientPackageName](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setClientPackageName(kotlin.String))`(`packageName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?`)` Sets the package name of the app using the route.                                                                                                                                                                                                                                                                      |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setConnectionState](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setConnectionState(kotlin.Int))`(`connectionState:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the route's connection state.                                                                                                                                                                                                                                                                                               |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setDeduplicationIds](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setDeduplicationIds(kotlin.collections.MutableSet))`(`id:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>`)` Sets the[deduplication IDs](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#getDeduplicationIds())of the route.                                                               |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setDescription](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setDescription(kotlin.CharSequence))`(`description:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?`)` Sets the user-visible description of the route.                                                                                                                                                                                                                                                                 |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setExtras](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setExtras(android.os.Bundle))`(`extras:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?`)` Sets a bundle of extras for the route.                                                                                                                                                                                                                                                                                                        |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setIconUri](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setIconUri(android.net.Uri))`(`iconUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)?`)` Sets the URI of the icon representing this route.                                                                                                                                                                                                                                                                                                 |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setRequiredPermissions](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setRequiredPermissions(kotlin.collections.MutableList))`(`requiresOneOf:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>!>`)` Limits the visibility of this route to holders of one of a set of permissions. |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setRequiredPermissions](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setRequiredPermissions(kotlin.collections.MutableSet))`(`requiredPermissions:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>`)` Limits the visibility of this route to holders of a set of permissions.                                                                                                             |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setSuitabilityStatus](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setSuitabilityStatus(kotlin.Int))`(`suitabilityStatus:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets route suitability status.                                                                                                                                                                                                                                                                                             |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setType](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setType(kotlin.Int))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the route's type.                                                                                                                                                                                                                                                                                                                                            |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setVisibilityPublic](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVisibilityPublic())`()` Sets the visibility of this route to public.                                                                                                                                                                                                                                                                                                                                                                                            |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setVisibilityRestricted](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVisibilityRestricted(kotlin.collections.MutableSet))`(`allowedPackages:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>`)` Sets the visibility of this route to restricted.                                                                                                                                      |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setVisibilityRestricted](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVisibilityRestricted(kotlin.collections.MutableSet,%20kotlin.Boolean))`(`allowedPackages:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>`, `alsoAllowPrivileged:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets the visibility of this route to restricted.       |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setVolume](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVolume(kotlin.Int))`(`volume:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the route's current volume, or 0 if unknown.                                                                                                                                                                                                                                                                                                           |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setVolumeHandling](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVolumeHandling(kotlin.Int))`(`volumeHandling:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the route's volume handling.                                                                                                                                                                                                                                                                                                   |
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | [setVolumeMax](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVolumeMax(kotlin.Int))`(`volumeMax:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the route's maximum volume, or 0 if unknown.                                                                                                                                                                                                                                                                                                  |

## Public constructors

### Builder

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(routeInfo: MediaRoute2Info)
```

Constructor for builder to create[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)with existing[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)instance.

|                                                                                    Parameters                                                                                     ||
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `routeInfo` | [MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info):the existing instance to copy data from. This value cannot be`null`. |

### Builder

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    id: String, 
    name: CharSequence)
```

Constructor for builder to create[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info).

In order to ensure ID uniqueness, the[ID](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#getId())of a route info obtained from[MediaRouter2](https://developer.android.com/reference/kotlin/android/media/MediaRouter2)can be different from what was set in[MediaRoute2ProviderService](https://developer.android.com/reference/kotlin/android/media/MediaRoute2ProviderService).

|                                                                              Parameters                                                                               ||
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The ID of the route. Must not be empty. This value cannot be`null`.          |
| `name` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):The user-visible name of the route. This value cannot be`null`. |

## Public methods

### addFeature

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun addFeature(feature: String): MediaRoute2Info.Builder
```

Adds a feature for the route.

|                                                                                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                                                                                            ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `feature` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):a feature that the route has. May be one of predefined features such as[FEATURE_LIVE_AUDIO](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#FEATURE_LIVE_AUDIO:kotlin.String),[FEATURE_LIVE_VIDEO](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#FEATURE_LIVE_VIDEO:kotlin.String)or[FEATURE_REMOTE_PLAYBACK](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#FEATURE_REMOTE_PLAYBACK:kotlin.String)or a custom feature defined by a provider. This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

**See Also**

- [#addFeatures(Collection)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#addFeatures(kotlin.collections.MutableCollection))  

### addFeatures

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun addFeatures(features: MutableCollection<String!>): MediaRoute2Info.Builder
```

Adds features for the route. A route must support at least one route type.

|                                                                                                                                                                                                                                                                                                                                                                                      Parameters                                                                                                                                                                                                                                                                                                                                                                                      ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `features` | [MutableCollection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>:features that the route has. May include predefined features such as[FEATURE_LIVE_AUDIO](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#FEATURE_LIVE_AUDIO:kotlin.String),[FEATURE_LIVE_VIDEO](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#FEATURE_LIVE_VIDEO:kotlin.String)or[FEATURE_REMOTE_PLAYBACK](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#FEATURE_REMOTE_PLAYBACK:kotlin.String)or custom features defined by a provider. This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

**See Also**

- [#addFeature(String)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#addFeature(kotlin.String))  

### build

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): MediaRoute2Info
```

Builds the[media route info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info).

|                                                            Return                                                            ||
|-------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info) | This value cannot be`null`. |

|                           Exceptions                            ||
|--------------------------------------|---------------------------|
| `java.lang.IllegalArgumentException` | if no features are added. |

### clearFeatures

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun clearFeatures(): MediaRoute2Info.Builder
```

Clears the features of the route. A route must support at least one route type.

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setClientPackageName

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setClientPackageName(packageName: String?): MediaRoute2Info.Builder
```

Sets the package name of the app using the route.

|                                                        Parameters                                                         ||
|---------------|------------------------------------------------------------------------------------------------------------|
| `packageName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?:This value may be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setConnectionState

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setConnectionState(connectionState: Int): MediaRoute2Info.Builder
```

Sets the route's connection state.[CONNECTION_STATE_DISCONNECTED](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#CONNECTION_STATE_DISCONNECTED:kotlin.Int),[CONNECTION_STATE_CONNECTING](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#CONNECTION_STATE_CONNECTING:kotlin.Int), or[CONNECTION_STATE_CONNECTED](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#CONNECTION_STATE_CONNECTED:kotlin.Int).

|                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                           ||
|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `connectionState` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.media.MediaRoute2Info#CONNECTION_STATE_DISCONNECTED](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#CONNECTION_STATE_DISCONNECTED:kotlin.Int),[android.media.MediaRoute2Info#CONNECTION_STATE_CONNECTING](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#CONNECTION_STATE_CONNECTING:kotlin.Int), or[android.media.MediaRoute2Info#CONNECTION_STATE_CONNECTED](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#CONNECTION_STATE_CONNECTED:kotlin.Int) |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setDeduplicationIds

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setDeduplicationIds(id: MutableSet<String!>): MediaRoute2Info.Builder
```

Sets the[deduplication IDs](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#getDeduplicationIds())of the route.

|                                                                                                          Parameters                                                                                                          ||
|------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>:This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setDescription

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setDescription(description: CharSequence?): MediaRoute2Info.Builder
```

Sets the user-visible description of the route.

|                                                               Parameters                                                               ||
|---------------|-------------------------------------------------------------------------------------------------------------------------|
| `description` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?:This value may be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setExtras

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setExtras(extras: Bundle?): MediaRoute2Info.Builder
```

Sets a bundle of extras for the route.

Note: The extras will not affect the result of[MediaRoute2Info.equals(Object)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#equals(kotlin.Any)).

|                                                      Parameters                                                      ||
|----------|------------------------------------------------------------------------------------------------------------|
| `extras` | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)?:This value may be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setIconUri

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setIconUri(iconUri: Uri?): MediaRoute2Info.Builder
```

Sets the URI of the icon representing this route.

This icon will be used in picker UIs if available.

The URI must be one of the following formats:

- content ([android.content.ContentResolver#SCHEME_CONTENT](https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#SCHEME_CONTENT:kotlin.String))
- android.resource ([android.content.ContentResolver#SCHEME_ANDROID_RESOURCE](https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#SCHEME_ANDROID_RESOURCE:kotlin.String))
- file ([android.content.ContentResolver#SCHEME_FILE](https://developer.android.com/reference/kotlin/android/content/ContentResolver.html#SCHEME_FILE:kotlin.String))

<br />

|                                                    Parameters                                                    ||
|-----------|-------------------------------------------------------------------------------------------------------|
| `iconUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)?:This value may be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setRequiredPermissions

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setRequiredPermissions(requiresOneOf: MutableList<MutableSet<String!>!>): MediaRoute2Info.Builder
```

Limits the visibility of this route to holders of one of a set of permissions.

Calls to this method override any previous calls of[setRequiredPermissions(java.util.Set)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setRequiredPermissions(kotlin.collections.MutableSet))or[setRequiredPermissions(java.util.List)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setRequiredPermissions(kotlin.collections.MutableList)).

|                                                                                                                                                                                                                                   Parameters                                                                                                                                                                                                                                    ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `requiresOneOf` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!\>:a list of Sets of permissions. Holding all permissions in at least one of the Sets is required for the route to be visible. This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setRequiredPermissions

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setRequiredPermissions(requiredPermissions: MutableSet<String!>): MediaRoute2Info.Builder
```

Limits the visibility of this route to holders of a set of permissions.

Calls to this method override any previous calls of[setRequiredPermissions(java.util.Set)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setRequiredPermissions(kotlin.collections.MutableSet))or[setRequiredPermissions(java.util.List)](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setRequiredPermissions(kotlin.collections.MutableList)).

|                                                                                                                                                        Parameters                                                                                                                                                        ||
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `requiredPermissions` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>:the list of all permissions which must be held in order to see this route. This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setSuitabilityStatus

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setSuitabilityStatus(suitabilityStatus: Int): MediaRoute2Info.Builder
```

Sets route suitability status.

The default value is[android.media.MediaRoute2Info#SUITABILITY_STATUS_SUITABLE_FOR_DEFAULT_TRANSFER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#SUITABILITY_STATUS_SUITABLE_FOR_DEFAULT_TRANSFER:kotlin.Int).

Apps are not supposed to set[android.media.MediaRoute2Info#SUITABILITY_STATUS_NOT_SUITABLE_FOR_TRANSFER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#SUITABILITY_STATUS_NOT_SUITABLE_FOR_TRANSFER:kotlin.Int). Publishing a non-system route with such status throws[SecurityException](https://developer.android.com/reference/kotlin/java/lang/SecurityException.html#).

|                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                     ||
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `suitabilityStatus` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.media.MediaRoute2Info#SUITABILITY_STATUS_SUITABLE_FOR_DEFAULT_TRANSFER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#SUITABILITY_STATUS_SUITABLE_FOR_DEFAULT_TRANSFER:kotlin.Int),[android.media.MediaRoute2Info#SUITABILITY_STATUS_SUITABLE_FOR_MANUAL_TRANSFER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#SUITABILITY_STATUS_SUITABLE_FOR_MANUAL_TRANSFER:kotlin.Int), or[android.media.MediaRoute2Info#SUITABILITY_STATUS_NOT_SUITABLE_FOR_TRANSFER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#SUITABILITY_STATUS_NOT_SUITABLE_FOR_TRANSFER:kotlin.Int) |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setType

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setType(type: Int): MediaRoute2Info.Builder
```

Sets the route's type.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|--------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.media.MediaRoute2Info#TYPE_UNKNOWN](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_UNKNOWN:kotlin.Int),[android.media.MediaRoute2Info#TYPE_BUILTIN_SPEAKER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_BUILTIN_SPEAKER:kotlin.Int),[android.media.MediaRoute2Info#TYPE_WIRED_HEADSET](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_WIRED_HEADSET:kotlin.Int),[android.media.MediaRoute2Info#TYPE_WIRED_HEADPHONES](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_WIRED_HEADPHONES:kotlin.Int),[android.media.MediaRoute2Info#TYPE_BLUETOOTH_A2DP](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_BLUETOOTH_A2DP:kotlin.Int),[android.media.MediaRoute2Info#TYPE_HDMI](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_HDMI:kotlin.Int),[android.media.MediaRoute2Info#TYPE_HDMI_ARC](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_HDMI_ARC:kotlin.Int),[android.media.MediaRoute2Info#TYPE_HDMI_EARC](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_HDMI_EARC:kotlin.Int),[android.media.MediaRoute2Info#TYPE_LINE_DIGITAL](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_LINE_DIGITAL:kotlin.Int),[android.media.MediaRoute2Info#TYPE_LINE_ANALOG](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_LINE_ANALOG:kotlin.Int),[android.media.MediaRoute2Info#TYPE_AUX_LINE](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_AUX_LINE:kotlin.Int),[android.media.MediaRoute2Info#TYPE_USB_DEVICE](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_USB_DEVICE:kotlin.Int),[android.media.MediaRoute2Info#TYPE_USB_ACCESSORY](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_USB_ACCESSORY:kotlin.Int),[android.media.MediaRoute2Info#TYPE_DOCK](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_DOCK:kotlin.Int),[android.media.MediaRoute2Info#TYPE_USB_HEADSET](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_USB_HEADSET:kotlin.Int),[android.media.MediaRoute2Info#TYPE_HEARING_AID](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_HEARING_AID:kotlin.Int),[android.media.MediaRoute2Info#TYPE_BLE_HEADSET](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_BLE_HEADSET:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_TV](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_TV:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_SPEAKER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_SPEAKER:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_AUDIO_VIDEO_RECEIVER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_AUDIO_VIDEO_RECEIVER:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_TABLET](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_TABLET:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_TABLET_DOCKED](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_TABLET_DOCKED:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_COMPUTER](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_COMPUTER:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_GAME_CONSOLE](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_GAME_CONSOLE:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_CAR](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_CAR:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_SMARTWATCH](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_SMARTWATCH:kotlin.Int),[android.media.MediaRoute2Info#TYPE_REMOTE_SMARTPHONE](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_REMOTE_SMARTPHONE:kotlin.Int), or[android.media.MediaRoute2Info#TYPE_GROUP](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#TYPE_GROUP:kotlin.Int) |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

**See Also**

- [android.media.MediaRoute2Info#getType()](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#getType())  

### setVisibilityPublic

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVisibilityPublic(): MediaRoute2Info.Builder
```

Sets the visibility of this route to public.

By default, unless you call #setVisibilityRestricted, the new route will be public.

Public routes are visible to any application with a matching[feature](https://developer.android.com/reference/kotlin/android/media/RouteDiscoveryPreference#getPreferredFeatures()).

Calls to this method override previous calls to[setVisibilityPublic](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVisibilityPublic())and #setVisibilityRestricted.

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setVisibilityRestricted

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVisibilityRestricted(allowedPackages: MutableSet<String!>): MediaRoute2Info.Builder
```

Sets the visibility of this route to restricted.

Routes with restricted visibility are only visible to its publisher application and applications whose package name is included in the provided`allowedPackages`set with a matching[feature](https://developer.android.com/reference/kotlin/android/media/RouteDiscoveryPreference#getPreferredFeatures()).

Calls to this method override previous calls to[setVisibilityPublic](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVisibilityPublic())and #setVisibilityRestricted.

|                                                                                                                                             Parameters                                                                                                                                              ||
|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `allowedPackages` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>:set of package names which are allowed to see this route. This value cannot be`null`. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

**See Also**

- [#setVisibilityPublic](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#setVisibilityPublic())  

### setVisibilityRestricted

Added in[API level 36.1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVisibilityRestricted(
    allowedPackages: MutableSet<String!>, 
    alsoAllowPrivileged: Boolean
): MediaRoute2Info.Builder
```

Sets the visibility of this route to restricted.

|                                                                                                                                                                                                             Parameters                                                                                                                                                                                                             ||
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `allowedPackages`     | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>:set of package names which are allowed to see this route. This value cannot be`null`.                                                                                                                            |
| `alsoAllowPrivileged` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):whether packages not explicitly listed in allowedPackages, but holding[privileged routing permissions](https://developer.android.com/reference/kotlin/android/media/MediaRouter2#getInstance(android.content.Context,%20kotlin.String,%20java.util.concurrent.Executor,%20java.lang.Runnable)), can also see this route. |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setVolume

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVolume(volume: Int): MediaRoute2Info.Builder
```

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

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setVolumeHandling

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVolumeHandling(volumeHandling: Int): MediaRoute2Info.Builder
```

Sets the route's volume handling.

|                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                        ||
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `volumeHandling` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.media.MediaRoute2Info#PLAYBACK_VOLUME_FIXED](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#PLAYBACK_VOLUME_FIXED:kotlin.Int), or[android.media.MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info#PLAYBACK_VOLUME_VARIABLE:kotlin.Int) |

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |

### setVolumeMax

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVolumeMax(volumeMax: Int): MediaRoute2Info.Builder
```

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

|                                                                    Return                                                                     ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaRoute2Info.Builder](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info.Builder#) | This value cannot be`null`. |