-
Notifications
You must be signed in to change notification settings - Fork 2
Audio Device Manager
AudioDeviceManager is an interface for managing audio devices, including listing available devices, determining the currently active device, and switching between different audio devices.
Infobip RTC Android SDK supports the following devices:
- Earpiece
- Speaker
- Wired headset
- Bluetooth headset
By default, the earpiece is the primary audio device for devices that support telephony features, such as Android phones. For Android tablets, the speaker is the default audio device.
If an audio device is not explicitly selected using the selectAudioDevice
method, the audio device is selected automatically based on the following priority order:
- Bluetooth headset (if connected)
- Wired headset (if connected)
- Earpiece (if available)
- Speaker
When an active audio device is selected using the selectAudioDevice
method, the active device is switched to the selected device. If the selection of a specific device fails, the active
device is chosen based on the following criteria:
- If the previously active device was explicitly selected using
the
selectAudioDevice
method, it remains the active device. - If the previously active device was not explicitly selected using
the
selectAudioDevice
method, the active audio device is selected automatically based on the priority order.
Here's an example to illustrate the behavior:
- A bluetooth headset is connected.
- A call is started, and the bluetooth headset becomes the active device.
- The user selects the speaker as the active device, so the speaker becomes the active device.
- The user tries to select the bluetooth headset as the active device, but the operation fails. In this case, the previously active device (speaker) is retained as the active device.
- The user tries to select the bluetooth headset again as the active device, but the operation fails again. Since the previously active device (speaker) was selected automatically and not by user selection, it does not become the active device. Instead, the earpiece is chosen as the active device.
If an audio device is selected using the selectAudioDevice
method, and a
higher priority device (wired or bluetooth headset) is connected during a call, the active audio device is switched to
the newly connected device.
Consider the following example:
- A bluetooth headset is connected.
- A call is started, and the bluetooth headset becomes the active device.
- The user selects the speaker as the active device, so the speaker becomes the active device.
- A wired headset is connected, and it has a higher priority level than the active device. As a result, the wired headset becomes the active device, overriding the previously selected speaker.
During a call, if a wired or bluetooth headset is disconnected and an active audio device was selected explicitly using
the selectAudioDevice
method, the previously selected audio device becomes
the active device.
For instance:
- A call is started, and the default device becomes the active device.
- The user selects the speaker as the active device, so the speaker becomes the active device.
- A wired headset is connected, and the wired headset becomes the active device.
- The wired headset is disconnected, and the speaker becomes the active device.
If a newly connected device has lower priority than the active device, the audio device will not be switched to the newly connected device. The active device will retain its status.
Consider the following example:
- A bluetooth headset is connected.
- A call is started, and the bluetooth headset becomes the active device.
- A wired headset is connected, but the active device remains the bluetooth headset since it has higher priority.
If the active audio device (wired or bluetooth headset) is disconnected, and the active device was not explicitly
selected using the selectAudioDevice
method, the active audio device will
be selected based on the priority order.
Here's an example to illustrate the behavior:
- A wired headset is connected.
- A call is started, and the wired headset becomes the active device.
- A bluetooth headset is connected, and the bluetooth headset becomes the active device.
- The user selects the wired headset as the active device, so the wired headset becomes the active device.
- The wired headset is disconnected, and the bluetooth headset becomes the active device.
- The bluetooth headset is disconnected, and the default device becomes the active device.
Please note the following:
- Bluetooth audio devices can only be monitored and used
if
BLUETOOTH_CONNECT
permission is granted for an application withtargetSdk
31 or higher, running on Android 12 or higher. - It is not possible to select earpiece as the audio device while a wired headset is connected.
If you encounter difficulties when attempting to switch to a bluetooth headset while a wired headset is connected to your Android device, it is likely due to the audio routing priorities set by the Android system. By default, the system prioritizes audio output through the wired connection, potentially causing the bluetooth headset to be unrecognized or given lower priority for audio output.
To resolve this issue, we recommend following these steps:
- Disconnect both the bluetooth headset and the wired headset from your Android device.
- Reconnect the wired headset first and ensure that it is properly recognized by the Android device.
- Once the wired headset is successfully connected and functioning, you can proceed to use the bluetooth headset.
- Attempt to connect the bluetooth headset and ensure it is properly paired and connected to the Android device.
- By following this sequence, the Android system should recognize the bluetooth headset as the primary audio output device and allow you to switch to bluetooth headset successfully.
It's important to note that the behavior and effectiveness of these steps can vary depending on the specific device and any modifications made by the device manufacturer to the Android system. Please be aware that the Android SDK does not provide direct programmatic control over audio routing preferences, and the suggested steps rely on manual user actions.