java类android.bluetooth.BluetoothClass.Device的实例源码

BluetoothUtils8.java 文件源码 项目:CSipSimple 阅读 26 收藏 0 点赞 0 评论 0
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;
}
Bluetooth.java 文件源码 项目:cInterphone 阅读 30 收藏 0 点赞 0 评论 0
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;
}
Bluetooth.java 文件源码 项目:phonty 阅读 43 收藏 0 点赞 0 评论 0
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;
}
GlassConnection.java 文件源码 项目:JoeGlass 阅读 32 收藏 0 点赞 0 评论 0
public abstract void onDeviceDiscovered(Device device);


问题


面经


文章

微信
公众号

扫码关注公众号