[英]Determine type of connected Bluetooth device in android
When i pair a bluetooth mouse/keyboard to android device i can see mouse/keyboard icon near the device name. 当我将蓝牙鼠标/键盘与Android设备配对时,我可以看到设备名称附近的鼠标/键盘图标。 How can i determine in code the type of those paired devices?
如何在代码中确定配对设备的类型?
This is the way to get type of the Bluetooth device. 这是获取蓝牙设备类型的方法。
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;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.