BluetoothUtils8.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:CSipSimple 作者:
public boolean canBluetooth() {
    // Detect if any bluetooth a device is available for call
    if (bluetoothAdapter == null) {
        // Device does not support Bluetooth
        return false;
    }
    boolean hasConnectedDevice = false;
    //If bluetooth is on
    if(bluetoothAdapter.isEnabled()) {

        //We get all bounded bluetooth devices
        // bounded is not enough, should search for connected devices....
        Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();
        for(BluetoothDevice device : pairedDevices) {
            BluetoothClass bluetoothClass = device.getBluetoothClass();
               if (bluetoothClass != null) {
                int deviceClass = bluetoothClass.getDeviceClass();
                if(bluetoothClass.hasService(Service.RENDER) ||
                    deviceClass == Device.AUDIO_VIDEO_WEARABLE_HEADSET ||
                    deviceClass == Device.AUDIO_VIDEO_CAR_AUDIO ||
                    deviceClass == Device.AUDIO_VIDEO_HANDSFREE ) {
                        //And if any can be used as a audio handset
                        hasConnectedDevice = true;
                        break;
                }
            }
        }
    }
    boolean retVal = hasConnectedDevice && audioManager.isBluetoothScoAvailableOffCall();
    Log.d(THIS_FILE, "Can I do BT ? "+retVal);
    return retVal;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号