Java 类android.bluetooth.BluetoothClass.Service 实例源码

项目:CSipSimple    文件:BluetoothUtils8.java   
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;
}
项目:cInterphone    文件:Bluetooth.java   
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;
}
项目:phonty    文件:Bluetooth.java   
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;
}