Stay organized with collections
Save and categorize content based on your preferences.
VolumeCallback
abstract class VolumeCallback
Interface for receiving events about volume changes. All methods of this interface will be called from the application's main thread.
A VolumeCallback will only receive events relevant to routes that the callback was registered for.
Summary
Public methods |
abstract Unit |
Called when the volume for the route should be set to the given value
|
abstract Unit |
Called when the volume for the route should be increased or decreased.
|
Public constructors
VolumeCallback
VolumeCallback()
Public methods
onVolumeSetRequest
abstract fun onVolumeSetRequest(
info: MediaRouter.RouteInfo!,
volume: Int
): Unit
Called when the volume for the route should be set to the given value
onVolumeUpdateRequest
abstract fun onVolumeUpdateRequest(
info: MediaRouter.RouteInfo!,
direction: Int
): Unit
Called when the volume for the route should be increased or decreased.
Parameters |
info |
MediaRouter.RouteInfo!: the route affected by this event |
direction |
Int: an integer indicating whether the volume is to be increased (positive value) or decreased (negative value). For bundled changes, the absolute value indicates the number of changes in the same direction, e.g. +3 corresponds to three "volume up" changes. |
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,["# MediaRouter.VolumeCallback\n\nAdded in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nVolumeCallback\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/MediaRouter.VolumeCallback \"View this page in Java\") \n\n```\nabstract class VolumeCallback\n```\n\n|---|-----------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.media.MediaRouter.VolumeCallback](#) |\n\nInterface for receiving events about volume changes. All methods of this interface will be called from the application's main thread.\n\nA VolumeCallback will only receive events relevant to routes that the callback was registered for.\n\nSummary\n-------\n\n| Public constructors ||\n|------------------------------------------------|---|\n| [VolumeCallback](#VolumeCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onVolumeSetRequest](#onVolumeSetRequest(android.media.MediaRouter.RouteInfo,%20kotlin.Int))`(`info:` `[MediaRouter.RouteInfo](/reference/kotlin/android/media/MediaRouter.RouteInfo)!`, `volume:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the volume for the route should be set to the given value |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onVolumeUpdateRequest](#onVolumeUpdateRequest(android.media.MediaRouter.RouteInfo,%20kotlin.Int))`(`info:` `[MediaRouter.RouteInfo](/reference/kotlin/android/media/MediaRouter.RouteInfo)!`, `direction:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when the volume for the route should be increased or decreased. |\n\nPublic constructors\n-------------------\n\n### VolumeCallback\n\n```\nVolumeCallback()\n```\n\nPublic methods\n--------------\n\n### onVolumeSetRequest\n\nAdded in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onVolumeSetRequest(\n info: MediaRouter.RouteInfo!, \n volume: Int\n): Unit\n```\n\nCalled when the volume for the route should be set to the given value\n\n| Parameters ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `info` | [MediaRouter.RouteInfo](/reference/kotlin/android/media/MediaRouter.RouteInfo)!: the route affected by this event |\n| `volume` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): an integer indicating the new volume value that should be used, always between 0 and the value set by [UserRouteInfo.setVolumeMax(int)](/reference/kotlin/android/media/MediaRouter.UserRouteInfo#setVolumeMax(kotlin.Int)). |\n\n### onVolumeUpdateRequest\n\nAdded in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onVolumeUpdateRequest(\n info: MediaRouter.RouteInfo!, \n direction: Int\n): Unit\n```\n\nCalled when the volume for the route should be increased or decreased.\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `info` | [MediaRouter.RouteInfo](/reference/kotlin/android/media/MediaRouter.RouteInfo)!: the route affected by this event |\n| `direction` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): an integer indicating whether the volume is to be increased (positive value) or decreased (negative value). For bundled changes, the absolute value indicates the number of changes in the same direction, e.g. +3 corresponds to three \"volume up\" changes. |"]]