检查蓝牙设备是否有麦克风Android

时间:2015-01-13 06:20:17

标签: android bluetooth

在android中,即时尝试获取蓝牙配对设备列表,之后,如果耳机中有麦克风,请检查功能。

可以在android中找到它吗?

设置pairedDevices = bluetoothAdapter.getBondedDevices();

        for (BluetoothDevice device : pairedDevices) {

            BluetoothClass bluetoothClass = device.getBluetoothClass();



            if (bluetoothClass != null) {
                int deviceClass = bluetoothClass.getDeviceClass();



                if (deviceClass == Device.AUDIO_VIDEO_WEARABLE_HEADSET
                        || deviceClass == Device.AUDIO_VIDEO_CAR_AUDIO
                        || deviceClass == Device.AUDIO_VIDEO_HANDSFREE
                        || deviceClass == Device.AUDIO_VIDEO_UNCATEGORIZED


                        ) {
                           }
                       }
                  }

我如何从设备类知道它是否具有麦克风功能,或者如果返回的设备类是Device.AUDIO_VIDEO_WEARABLE_HEADSET,用户可以从设备通话?

1 个答案:

答案 0 :(得分:0)

您可以使用检查蓝牙设备的类:

private void getDeviceClass(BluetoothDevice device) {
  int btClass = device.getBluetoothClass().getDeviceClass();
  // check your device class; class constants are listed in the Reference link 
  // AUDIO_VIDEO_MICROPHONE, AUDIO_VIDEO_HANDSFREE,
  // or even PHONE_* may match your requirements
}

参考:BluetoothClass.Device