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; }
public static boolean isAvailable() { if (!ba.isEnabled()) return false; Set<BluetoothDevice> devs = ba.getBondedDevices(); for (final BluetoothDevice dev : devs) { BluetoothClass cl = dev.getBluetoothClass(); if (cl != null && (cl.hasService(Service.RENDER) || cl.getDeviceClass() == Device.AUDIO_VIDEO_HANDSFREE || cl.getDeviceClass() == Device.AUDIO_VIDEO_CAR_AUDIO || cl.getDeviceClass() == Device.AUDIO_VIDEO_WEARABLE_HEADSET)) return true; } return false; }