在 android 中确定连接的蓝牙设备的类型
Determine type of connected Bluetooth device in android
当我将蓝牙 mouse/keyboard 与 android 设备配对时,我可以在设备名称附近看到 mouse/keyboard 图标。
我如何在代码中确定那些配对设备的类型?
这是获取蓝牙设备类型的方法。
BluetoothClass cls = device.getBluetoothClass();
switch (cls.getMajorDeviceClass()) {
case BluetoothClass.Device.Major.PERIPHERAL:
switch (cls.getDeviceClass() & 0x05C0) {
case 0x0540: // Keyboard - 1314
break;
case 0x05C0: // Keyboard + mouse combo.
break;
case 0x0580: // Mouse - 1408
break;
default: // Other.
break;
}
}
当我将蓝牙 mouse/keyboard 与 android 设备配对时,我可以在设备名称附近看到 mouse/keyboard 图标。 我如何在代码中确定那些配对设备的类型?
这是获取蓝牙设备类型的方法。
BluetoothClass cls = device.getBluetoothClass();
switch (cls.getMajorDeviceClass()) {
case BluetoothClass.Device.Major.PERIPHERAL:
switch (cls.getDeviceClass() & 0x05C0) {
case 0x0540: // Keyboard - 1314
break;
case 0x05C0: // Keyboard + mouse combo.
break;
case 0x0580: // Mouse - 1408
break;
default: // Other.
break;
}
}