Java Code Examples for android.bluetooth.BluetoothClass.Device

The following examples show how to use android.bluetooth.BluetoothClass.Device. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: CSipSimple   Source File:    License: GNU General Public License v3.0 5 votes vote down vote up
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;
	boolean retVal = hasConnectedDevice && audioManager.isBluetoothScoAvailableOffCall();
	Log.d(THIS_FILE, "Can I do BT ? "+retVal);
	return retVal;
Example 2
Source Project: fdroidclient   Source File:    License: GNU General Public License v3.0 5 votes vote down vote up
 * Return a instance if the {@link BluetoothDevice} is a device that could
 * host a swap repo.
public static BluetoothPeer getInstance(@Nullable BluetoothDevice device) {
    if (device != null && device.getName() != null &&
            (device.getBluetoothClass().getDeviceClass() == Device.COMPUTER_HANDHELD_PC_PDA
                    || device.getBluetoothClass().getDeviceClass() == Device.COMPUTER_PALM_SIZE_PC_PDA
                    || device.getBluetoothClass().getDeviceClass() == Device.PHONE_SMART)) {
        return new BluetoothPeer(device);
    return null;
Example 3
Source Project: talkback   Source File:    License: Apache License 2.0 4 votes vote down vote up
@RequiresPermission(allOf = {permission.BLUETOOTH_ADMIN, permission.BLUETOOTH})
private void setDeviceIconResource(ComparableBluetoothDevice bluetoothDevice) {
  int imageResource;
  String description;
  /* Some bluetooth classes used to determine icon are inaccessible from outside of Android.
   * Because of this, the icons displayed here may not match the Android settings page exactly.
  BluetoothClass bluetoothClass = bluetoothDevice.getBluetoothClass();
  /* Show the default Bluetooth icon if the Bluetooth class is null. */
  int majorDeviceClass =
      (bluetoothClass == null) ? Major.MISC : bluetoothClass.getMajorDeviceClass();
  switch (majorDeviceClass) {
      case Major.COMPUTER:
        imageResource = R.drawable.ic_bluetooth_computer;
        description = descriptionManager.computerContentDescription();
      case Major.PHONE:
        imageResource = R.drawable.ic_bluetooth_phone;
        description = descriptionManager.phoneContentDescription();
      case Major.PERIPHERAL:
        imageResource = R.drawable.ic_bluetooth_peripheral;
        description = descriptionManager.peripheralContentDescription();
      case Major.IMAGING:
        imageResource = R.drawable.ic_bluetooth_imaging;
        description = descriptionManager.imagingContentDescription();
      case Major.AUDIO_VIDEO:
      // We can't get into this case if bluetoothClass is null because majorDeviceClass would
      // be Major.MISC not Major.AUDIO_VIDEO. deviceClass is a separate statement to allow
      // the warning suppression here rather than on the whole method.
      int deviceClass = bluetoothClass.getDeviceClass();
      if (deviceClass == Device.AUDIO_VIDEO_HEADPHONES) {
          imageResource = R.drawable.ic_bluetooth_headphone;
          description = descriptionManager.headphoneContentDescription();
        // Fall-through
        imageResource = R.drawable.ic_bluetooth_default;
        description = descriptionManager.defaultBluetoothDeviceContentDescription();