Rate this page:

IAudioDeviceManager

Interface that provides API to manage audio devices, i.e. see the current active device, select another active device and get the list of available devices.

Voximplant Android SDK supports the following devices:

  1. earpiece
  2. speaker
  3. wired headset
  4. Bluetooth headset

Default audio device

The earpiece is the default audio device for devices that supports telephony feature (android phones). The speaker is the default audio device for android tablets.

Before a call

If the audio device has been not selected via IAudioDeviceManager.selectAudioDevice(AudioDevice), it is selected according to the following priority order:

  1. Bluetooth (if connected)
  2. wired headset (if connected)
  3. earpiece (if available)
  4. speaker

If audio device has been selected via IAudioDeviceManager.selectAudioDevice(AudioDevice) and then a higher priority device is connected, the new device is used for a call. For example, speaker has been selected and then Bluetooth headset is connected, in this case Bluetooth device is used for a call.

During the call

If new audio device (wired headset or Bluetooth headset) is connected, active audio device is switched to the new connected audio device.

If the active audio device is disconnected (wired or Bluetooth headset), the active audio device is selected according to the priority order.

If the active audio device is selected via IAudioDeviceManager.selectAudioDevice(AudioDevice), the active audio device is switched to the selected device.

If the active audio device is selected via IAudioDeviceManager.selectAudioDevice(AudioDevice) and then new audio device is connected (wired or Bluetooth headset), the active audio device is switched to the new audio device. If wired or Bluetooth headset is disconnected during the same call, previously selected audio device becomes active.

For example:

  • wired headset is connected
  • call is started -> wired headset is active device
  • speaker is selected as active device -> speaker is active device
  • Bluetooth headset is connected -> Bluetooth is active device
  • Bluetooth headset is disconnected -> speaker is active device

Connection Service

If an application uses a self-managed ConnectionService to integrate Voximplant calls with the Telecom system framework, it is important to consider that there may be the conflicts of audio routing made by the Telecom system framework and the Voximplant SDK.

This conflict may result in a wrong audio device detection (such as Bluetooth or wired headset), incorrect audio device selection and switching.

To avoid unpredictable and undesirable behavior, use IAudioDeviceManager.setTelecomConnection(Connection) API to provide a new Telecom Connection associated with a Voximplant call before the call start/answer.

Find more information about Voximplant SDK and Connection Service integration in Android: ConnectionService guide.

Permissions

On Android 12 or higher, the BLUETOOTH_CONNECT permission is required. The permission should be granted before a call.

Without granting this permission, Bluetooth audio devices are not available.

BLUETOOTH_CONNECT permission is not required if:

  1. an application is running on the Android 11 or lower
  2. IAudioDeviceManager.setTelecomConnection(Connection) API is used

Limits:

  1. IAudioDeviceManager should be used only after IClient initialization via Voximplant.getClientInstance(Executor, Context, ClientConfig)
  2. The plug in/out of wired headsets is monitored only if the connection to the Voximplant cloud is active
  3. Bluetooth audio devices can be monitored and used if
    • Connection to the Voximplant cloud is active
    • BLUETOOTH_CONNECT permission is granted for an application with targetSdk 31 or higher and running on Android 12 or higher
  4. It is not possible to select earpiece while a wired headset is connected

Methods

addAudioDeviceEventsListener

Since ver. 2.3.4
Copy URL

void

addAudioDeviceEventsListener(

IAudioDeviceEventsListener

listener
)

Adds an IAudioDeviceEventsListener listener to handle audio device changes events.

Returns

  • type:

    void

getActiveDevice

Since ver. 2.3.4
Copy URL

AudioDevice

getActiveDevice()

Returns the active audio device during the call or audio device that is to be used in a call. if there is no calls at this moment.

Please note that active audio device can be later changed if new device is connected. In this case IAudioDeviceEventsListener.onAudioDeviceChanged(AudioDevice) is triggered to notify about new active device.

Returns

getAudioDevices

Since ver. 2.3.4
Copy URL

List<AudioDevice>

getAudioDevices()

Returns the list of available audio devices.

Returns

removeAudioDeviceEventsListener

Since ver. 2.3.4
Copy URL

void

removeAudioDeviceEventsListener(

IAudioDeviceEventsListener

listener
)

Removes an IAudioDeviceEventsListener listener.

Returns

  • type:

    void

selectAudioDevice

Since ver. 2.3.4
Copy URL

void

selectAudioDevice(

AudioDevice

audioDevice
)

Changes selection of the current active audio device. There are two cases:

  1. before a call. The method does not activate an audio device, it just selects (i.e. points to) the audio device to be activated
  2. during a call. If the selected audio device is available, the method activates this audio device.

When the call is ended, selected audio device is reset to the default one.

Please note that active audio device can be later changed if new device is connected.

In this case IAudioDeviceEventsListener.onAudioDeviceChanged(AudioDevice) is triggered to notify about new active device.

Parameters

Returns

  • type:

    void

setAudioFocusChangeListener

Copy URL

void

setAudioFocusChangeListener(

IAudioFocusChangeListener

listener
)

Sets an IAudioFocusChangeListener listener to handle audio focus change events.

Parameters

Returns

  • type:

    void

setTelecomConnection

Since ver. 2.35.0
Copy URL

void

setTelecomConnection(

Connection

connection
)

Sets a new Telecom Connection to manage audio devices if a self-managed ConnectionService is integrated with a Voximplant call.

A new Connection should be set before each call.

Requires Android API 26.

Parameters

  • connection:

    Connection

    Telecom Connection assosiated with a Voximplant call.

Returns

  • type:

    void