蓝牙事件返回奇怪的蓝牙设备类:240404
Weird bluetooth deviceClass is being returned by bluetooth event: 240404
我正在使用广播接收器来尝试查找蓝牙耳机何时 connect/disconnected 到 android 设备。
val filter = IntentFilter()
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED)
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED)
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED)
而我是这样处理事件的:
device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
val major = device?.bluetoothClass?.majorDeviceClass;
val bluetoothClass = device?.bluetoothClass ?: return
我得到的是
major
as 1024
(即 BluetoothClass.Device.Major.AUDIO_VIDEO
是正确的)
bluetoothClass.deviceClass
作为 240404
但 it is not listed as any of the recognized Bluetooth Devices.
我是不是用错了属性来比较?
我真傻,我是比较错误的东西。我要比较的是 deviceClass
property inside bluetoothClass
我正在使用广播接收器来尝试查找蓝牙耳机何时 connect/disconnected 到 android 设备。
val filter = IntentFilter()
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED)
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED)
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED)
而我是这样处理事件的:
device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE)
val major = device?.bluetoothClass?.majorDeviceClass;
val bluetoothClass = device?.bluetoothClass ?: return
我得到的是
major
as1024
(即BluetoothClass.Device.Major.AUDIO_VIDEO
是正确的)bluetoothClass.deviceClass
作为240404
但 it is not listed as any of the recognized Bluetooth Devices.
我真傻,我是比较错误的东西。我要比较的是 deviceClass
property inside bluetoothClass