distante
distante

Reputation: 7015

Weird bluetooth deviceClass is being returned by bluetooth event: 240404

I am using a broadcast receiver to try to find when a bluetooth headphone is connect/disconnected to an android device.

 val filter = IntentFilter()
        filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED)
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED)
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED)

And I handle the event in this way:

   device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
   val major = device?.bluetoothClass?.majorDeviceClass;
   val bluetoothClass = device?.bluetoothClass ?: return

What I get is

240404 Am I using the wrong property to compare it?

Upvotes: 1

Views: 200

Answers (1)

distante
distante

Reputation: 7015

So silly me, I was comparing the wrong thing. What I have to compare is the deviceClass property inside bluetoothClass

Upvotes: 0

Related Questions