Stay organized with collections
Save and categorize content based on your preferences.
RouteCallback
abstract class RouteCallback
Callback for receiving events about media route discovery.
Summary
Public methods |
open Unit |
Called when routes are added.
|
open Unit |
Called when the properties of one or more existing routes are changed.
|
open Unit |
Called when routes are removed.
|
open Unit |
Called when the route list is updated, which can happen when routes are added, removed, or modified.
|
Public constructors
RouteCallback
RouteCallback()
Public methods
onRoutesUpdated
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<MediaRoute2Info!>: the updated list of routes filtered by the callback's individual discovery preferences. This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# MediaRouter2.RouteCallback\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nRouteCallback\n=============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/MediaRouter2.RouteCallback \"View this page in Java\") \n\n```\nabstract class RouteCallback\n```\n\n|---|-----------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.media.MediaRouter2.RouteCallback](#) |\n\nCallback for receiving events about media route discovery.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------|---|\n| [RouteCallback](#RouteCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesAdded](#onRoutesAdded(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\u003e`)` Called when routes are added. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesChanged](#onRoutesChanged(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\u003e`)` Called when the properties of one or more existing routes are changed. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesRemoved](#onRoutesRemoved(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\u003e`)` Called when routes are removed. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onRoutesUpdated](#onRoutesUpdated(kotlin.collections.MutableList))`(`routes:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\u003e`)` Called when the route list is updated, which can happen when routes are added, removed, or modified. |\n\nPublic constructors\n-------------------\n\n### RouteCallback\n\n```\nRouteCallback()\n```\n\nPublic methods\n--------------\n\n### onRoutesAdded\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onRoutesAdded(routes: MutableList\u003cMediaRoute2Info!\u003e): Unit\n```\n\n**Deprecated:** *Use [onRoutesUpdated(java.util.List)](#onRoutesUpdated(kotlin.collections.MutableList)) instead.*\n\nCalled when routes are added. Whenever you register a callback, this will be invoked with known routes.\n\n| Parameters ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\\\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\\\u003e: the list of routes that have been added. It's never empty. This value cannot be `null`. |\n\n### onRoutesChanged\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onRoutesChanged(routes: MutableList\u003cMediaRoute2Info!\u003e): Unit\n```\n\n**Deprecated:** *Use [onRoutesUpdated(java.util.List)](#onRoutesUpdated(kotlin.collections.MutableList)) instead.*\n\nCalled 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.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\\\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\\\u003e: the list of routes that have been changed. It's never empty. This value cannot be `null`. |\n\n### onRoutesRemoved\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onRoutesRemoved(routes: MutableList\u003cMediaRoute2Info!\u003e): Unit\n```\n\n**Deprecated:** *Use [onRoutesUpdated(java.util.List)](#onRoutesUpdated(kotlin.collections.MutableList)) instead.*\n\nCalled when routes are removed.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\\\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\\\u003e: the list of routes that have been removed. It's never empty. This value cannot be `null`. |\n\n### onRoutesUpdated\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onRoutesUpdated(routes: MutableList\u003cMediaRoute2Info!\u003e): Unit\n```\n\nCalled 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.\n\n| Parameters ||\n|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `routes` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\\\u003c[MediaRoute2Info](/reference/kotlin/android/media/MediaRoute2Info)!\\\u003e: the updated list of routes filtered by the callback's individual discovery preferences. This value cannot be `null`. |"]]