Stay organized with collections
Save and categorize content based on your preferences.
AudioDeviceCallback
abstract class AudioDeviceCallback
AudioDeviceCallback defines the mechanism by which applications can receive notifications of audio device connection and disconnection events.
Summary
Public methods |
open Unit |
Called by the AudioManager to indicate that one or more audio devices have been connected.
|
open Unit |
Called by the AudioManager to indicate that one or more audio devices have been disconnected.
|
Public constructors
AudioDeviceCallback
AudioDeviceCallback()
Public methods
onAudioDevicesAdded
open fun onAudioDevicesAdded(addedDevices: Array<AudioDeviceInfo!>!): Unit
Called by the AudioManager
to indicate that one or more audio devices have been connected.
onAudioDevicesRemoved
open fun onAudioDevicesRemoved(removedDevices: Array<AudioDeviceInfo!>!): Unit
Called by the AudioManager
to indicate that one or more audio devices have been disconnected.
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,["# AudioDeviceCallback\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAudioDeviceCallback\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/AudioDeviceCallback \"View this page in Java\") \n\n```\nabstract class AudioDeviceCallback\n```\n\n|---|----------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.media.AudioDeviceCallback](#) |\n\nAudioDeviceCallback defines the mechanism by which applications can receive notifications of audio device connection and disconnection events.\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------------------|---|\n| [AudioDeviceCallback](#AudioDeviceCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onAudioDevicesAdded](#onAudioDevicesAdded(kotlin.Array))`(`addedDevices:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\u003c[AudioDeviceInfo](/reference/kotlin/android/media/AudioDeviceInfo)!\u003e!`)` Called by the [AudioManager](/reference/kotlin/android/media/AudioManager) to indicate that one or more audio devices have been connected. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onAudioDevicesRemoved](#onAudioDevicesRemoved(kotlin.Array))`(`removedDevices:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\u003c[AudioDeviceInfo](/reference/kotlin/android/media/AudioDeviceInfo)!\u003e!`)` Called by the [AudioManager](/reference/kotlin/android/media/AudioManager) to indicate that one or more audio devices have been disconnected. |\n\nPublic constructors\n-------------------\n\n### AudioDeviceCallback\n\n```\nAudioDeviceCallback()\n```\n\nPublic methods\n--------------\n\n### onAudioDevicesAdded\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onAudioDevicesAdded(addedDevices: Array\u003cAudioDeviceInfo!\u003e!): Unit\n```\n\nCalled by the [AudioManager](/reference/kotlin/android/media/AudioManager) to indicate that one or more audio devices have been connected.\n\n| Parameters ||\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `addedDevices` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\\\u003c[AudioDeviceInfo](/reference/kotlin/android/media/AudioDeviceInfo)!\\\u003e!: An array of [AudioDeviceInfo](/reference/kotlin/android/media/AudioDeviceInfo) objects corresponding to any newly added audio devices. |\n\n### onAudioDevicesRemoved\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onAudioDevicesRemoved(removedDevices: Array\u003cAudioDeviceInfo!\u003e!): Unit\n```\n\nCalled by the [AudioManager](/reference/kotlin/android/media/AudioManager) to indicate that one or more audio devices have been disconnected.\n\n| Parameters ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `removedDevices` | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\\\u003c[AudioDeviceInfo](/reference/kotlin/android/media/AudioDeviceInfo)!\\\u003e!: An array of [AudioDeviceInfo](/reference/kotlin/android/media/AudioDeviceInfo) objects corresponding to any newly removed audio devices. |"]]