AudioCapabilitiesReceiver


@UnstableApi
class AudioCapabilitiesReceiver


Receives broadcast events indicating changes to the device's audio capabilities, notifying a Listener when audio capability changes occur.

Summary

Nested types

Listener notified when audio capabilities change.

Public constructors

This function is deprecated.

Use AudioCapabilitiesReceiver instead.

AudioCapabilitiesReceiver(
    context: Context!,
    listener: AudioCapabilitiesReceiver.Listener!,
    audioAttributes: AudioAttributes!,
    routedDevice: AudioDeviceInfo?
)

Public functions

AudioCapabilities!

Registers the receiver, meaning it will notify the listener when audio capability changes occur.

Unit

Updates the AudioAttributes used by this instance.

Unit
@RequiresApi(value = 23)
setRoutedDevice(routedDevice: AudioDeviceInfo?)

Updates the AudioDeviceInfo audio will be routed to.

Unit

Unregisters the receiver, meaning it will no longer notify the listener when audio capability changes occur.

Public constructors

AudioCapabilitiesReceiver

AudioCapabilitiesReceiver(
    context: Context!,
    listener: AudioCapabilitiesReceiver.Listener!
)

AudioCapabilitiesReceiver

AudioCapabilitiesReceiver(
    context: Context!,
    listener: AudioCapabilitiesReceiver.Listener!,
    audioAttributes: AudioAttributes!,
    routedDevice: AudioDeviceInfo?
)
Parameters
context: Context!

A context for registering the receiver.

listener: AudioCapabilitiesReceiver.Listener!

The listener to notify when audio capabilities change.

audioAttributes: AudioAttributes!

The AudioAttributes.

routedDevice: AudioDeviceInfo?

The AudioDeviceInfo audio will be routed to if known, or null to assume the default route.

Public functions

register

fun register(): AudioCapabilities!

Registers the receiver, meaning it will notify the listener when audio capability changes occur. The current audio capabilities will be returned. It is important to call unregister when the receiver is no longer required.

Returns
AudioCapabilities!

The current audio capabilities for the device.

setAudioAttributes

fun setAudioAttributes(audioAttributes: AudioAttributes!): Unit

Updates the AudioAttributes used by this instance.

Parameters
audioAttributes: AudioAttributes!

The AudioAttributes.

setRoutedDevice

@RequiresApi(value = 23)
fun setRoutedDevice(routedDevice: AudioDeviceInfo?): Unit

Updates the AudioDeviceInfo audio will be routed to.

Parameters
routedDevice: AudioDeviceInfo?

The AudioDeviceInfo audio will be routed to if known, or null to assume the default route.

unregister

fun unregister(): Unit

Unregisters the receiver, meaning it will no longer notify the listener when audio capability changes occur.