Bluetoothprofile.ServiceListener : onServiceConnected not called on some devices

Viewed 214

I'm using the HidDevice profile that was introduced in SDK 28.

MinSDK is also 28

On some devices onServiceConnected gets called immediately, on others it never gets called. I haven't seen a pattern on the devices where it works/doesn't work.

This is the line that is "registering" the ServiceListener

bluetoothAdapter.getProfileProxy(applicationContext,serviceListener,BluetoothProfile.HID_DEVICE)

And this is the ServiceListener with sample code

val serviceListener = object : BluetoothProfile.ServiceListener {

    override fun onServiceConnected(profile: Int, proxy: BluetoothProfile) {
        throw RuntimeException("Not called on some devices")
    }

    override fun onServiceDisconnected(profile: Int) {
        throw RuntimeException("Not called on some devices")
    }
}
0 Answers
Related