# MediaRouter2.RouteCallback

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

# RouteCallback

*** ** * ** ***

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

```
abstract class RouteCallback
```

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

Callback for receiving events about media route discovery.

## Summary

|                                                          Public constructors                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------------|---|
| [RouteCallback](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#RouteCallback())`()` <br /> |

|                                                                                                                                                                                                                                                                               Public methods                                                                                                                                                                                                                                                                               ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesAdded](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesAdded(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!>`)` Called when routes are added.                                                                            |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesChanged](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesChanged(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!>`)` Called when the properties of one or more existing routes are changed.                               |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesRemoved](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesRemoved(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!>`)` Called when routes are removed.                                                                      |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesUpdated](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesUpdated(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!>`)` Called when the route list is updated, which can happen when routes are added, removed, or modified. |

## Public constructors

### RouteCallback

```
RouteCallback()
```

## Public methods

### onRoutesAdded

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

```
open fun onRoutesAdded(routes: MutableList<MediaRoute2Info!>): Unit
```

**Deprecated:** *Use[onRoutesUpdated(java.util.List)](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesUpdated(kotlin.collections.MutableList))instead.*

Called when routes are added. Whenever you register a callback, this will be invoked with known routes.

|                                                                                                                                                  Parameters                                                                                                                                                  ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!\>:the list of routes that have been added. It's never empty. This value cannot be`null`. |

### onRoutesChanged

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

```
open fun onRoutesChanged(routes: MutableList<MediaRoute2Info!>): Unit
```

**Deprecated:** *Use[onRoutesUpdated(java.util.List)](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesUpdated(kotlin.collections.MutableList))instead.*

Called when the properties of one or more existing routes are changed. For example, it is called when a route's name or volume have changed.

|                                                                                                                                                   Parameters                                                                                                                                                   ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!\>:the list of routes that have been changed. It's never empty. This value cannot be`null`. |

### onRoutesRemoved

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

```
open fun onRoutesRemoved(routes: MutableList<MediaRoute2Info!>): Unit
```

**Deprecated:** *Use[onRoutesUpdated(java.util.List)](https://developer.android.com/reference/kotlin/android/media/MediaRouter2.RouteCallback#onRoutesUpdated(kotlin.collections.MutableList))instead.*

Called when routes are removed.

|                                                                                                                                                   Parameters                                                                                                                                                   ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!\>:the list of routes that have been removed. It's never empty. This value cannot be`null`. |

### onRoutesUpdated

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

```
open fun onRoutesUpdated(routes: MutableList<MediaRoute2Info!>): Unit
```

Called when the route list is updated, which can happen when routes are added, removed, or modified. It will also be called when a route callback is registered.

|                                                                                                                                                                Parameters                                                                                                                                                                 ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[MediaRoute2Info](https://developer.android.com/reference/kotlin/android/media/MediaRoute2Info)!\>:the updated list of routes filtered by the callback's individual discovery preferences. This value cannot be`null`. |