Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 检查蓝牙设备是否有麦克风_Android_Bluetooth - Fatal编程技术网

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

Android 检查蓝牙设备是否有麦克风,android,bluetooth,Android,Bluetooth,在安卓系统中,我正在尝试获取蓝牙配对设备列表,然后检查耳机中是否有麦克风 有可能在android中找到它吗 Set pairedDevices=bluetoothAdapter.getBondedDevices() 如何从设备类中知道它是否具有麦克风功能,或者如果返回的设备类是device.AUDIO\u VIDEO\u WEARABLE\u HEADSET,则用户可以通过设备进行通话?您可以使用检查蓝牙设备的类: private void getDeviceClass(BluetoothDev

在安卓系统中,我正在尝试获取蓝牙配对设备列表,然后检查耳机中是否有麦克风

有可能在android中找到它吗

Set pairedDevices=bluetoothAdapter.getBondedDevices()


如何从设备类中知道它是否具有麦克风功能,或者如果返回的设备类是device.AUDIO\u VIDEO\u WEARABLE\u HEADSET,则用户可以通过设备进行通话?

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

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
}

参考资料:

我编辑了我的原始问题,问题是,在支持蓝牙的bose音频扬声器中,设备类返回Device.audio\u VIDEO\u WEARABLE\u HEADSET。但bose音频扬声器没有麦克风功能。我正在开发一个拨号应用程序,如果设备没有麦克风功能,它不应该将音频路由到扬声器。这会记录一小段音频并检查音频是否有音量。也许你可以做类似的逻辑。Don think是一个好的解决方案,在我的拨号应用程序中,当呼叫连接时,我需要决定音频的路由,并使用耳机麦克风输入或设备麦克风输入。用户可能不会说话,在这种情况下,音频也不会有任何音量。当耳机中没有麦克风时,手机的默认拨号应用程序会这样做,因此确定mi的功能时,它不会将音频路由到耳机。
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
}