Did anyone have a successful experience on working with CompanionDeviceManager
on Android? Especially, with the devices with Bluetooth Classic support. I've been testing a pretty simple app which tries to connect some device using Bluetooth Classic and I keep getting different strange errors. The problems I'm facing:
- The internals of
CompanionDeviceManager
can crash with some nullpointer - The API uses
onActivityResult
mechanism and often I just get this callback with unsuccessful result (!Activity.RESULT_OK) - But most importantly, it takes way too long to discover a device
So, am I doing something wrong? Or this API is quite unstable?
Make sure that your bluetooth device filter is of type BluetoothDeviceFilter, which is for Bluetooth Classic devices, unlike BluetoothLeDeviceFilter which is for Bluetooth Low Energy devices.
Code sample:
Then when you attempt to check if the device is paired/unpaired via ActivityResult API, do note that you'll be receiving Parcelable Extra of type ScanResult when it's a Bluetooth LE device, and a Parcelable Extra of type BluetoothDevice when it's a Bluetooth Classic device: