Reputation: 7015
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
major
as 1024
(that is BluetoothClass.Device.Major.AUDIO_VIDEO
which is correct)bluetoothClass.deviceClass
as 240404
but it is not listed as any of the recognized Bluetooth Devices.
Am I using the wrong property to compare it?
Upvotes: 1
Views: 200
Reputation: 7015
So silly me, I was comparing the wrong thing. What I have to compare is the deviceClass
property inside bluetoothClass
Upvotes: 0