【问题标题】:Determine type of connected Bluetooth device in android在android中确定连接的蓝牙设备的类型
【发布时间】:2015-06-13 08:55:42
【问题描述】:

当我将蓝牙鼠标/键盘与安卓设备配对时,我可以在设备名称附近看到鼠标/键盘图标。 如何在代码中确定这些配对设备的类型?

【问题讨论】:

    标签: android bluetooth


    【解决方案1】:

    这是获取蓝牙设备类型的方法。

        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;
                    }
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-24
      • 1970-01-01
      • 1970-01-01
      • 2014-08-08
      • 1970-01-01
      相关资源
      最近更新 更多