This Android library helps managing the various event and feature around external peripherals, sound outputs
dependencies {
//add this one if you want to use the logic-only SDK
compile ('io.dolby:audio:2.5.2') {
transitive = true
}
}
Breaking change : a new version exists which now by default sets the Wired Headset mode as stream music
instead of call mode. This is forced by design until a new version of the library lets full control
over which device and what mode to use. In the meantime, if the previous mode is required, you can
use WiredMode.SetAsMusic = false
.
AudioDeviceManager manager = new AudioDeviceManager(Context, ListenerForUpdates);
Promise<List<MediaDevice>> devices = manager.enumerateDevices();
Promise<List<MediaDevice>> devices = manager.enumerateDevices(DeviceType);
List<MediaDevice> filtered = manager.filter(List<MediaDevice>, DeviceType);
Promise<Boolean> connection = manager.connect(MediaDevice);
Promise<Boolean> connection = manager.disconnect(MediaDevice);
DeviceType {
INTERNAL_SPEAKER,
EXTERNAL_SPEAKER,
BLUETOOTH,
NORMAL_MEDIA,
WIRED_HEADSET,
USB
}
System's id for the wrapped device
Type of the current device
Current connection state from the SDK point of view
Current connection state from a platform point of view (a device can be connected to the platform but not used)
ConnectionState {
DISCONNECTED,
CONNECTING,
CONNECTED,
DISCONNECTING;
}
Ensure a device is plugged in the current desktop (multiple devices for more integration testing purposes)
And run the following command :
./gradlew :audio:connectedCheck test
The various test implementation results can be found in the following folders. Use the direct links to access your own results :
v2.3.0 :
- following Android 12 new behavior related to the permissions, to have properly the various bluetooth devices listed, you will need to ask explicitly the BLUETOOTH_CONNECT permission. Please refer to the permissions for Android 12 or higher article
- added catch block to prevent crash on permission-less app used on Android 12
v2.2.2 :
- merge wired_headset and internal_speaker into one default_speaker device
- fix behavior where plugging / unplugging wired headset wouldn't generate expected device update event
v2.x :
- asynchronous and safe use of various device manipulation
v1.0.5 :
- address issue on some HTC devices where the
getDefaultAdapter()
for Bluetooth would trigger a VerifyError
v1.0.4 :
- Improve Bluetooth management with a fix in the constructor to use the warmup method