如何检查是否已启用蓝牙编程?蓝牙

2023-09-14 23:01:45 作者:注定输给时间

我要检查,如果蓝牙技术是在任何Android设备定期启用。有没有办法,我能赶上使用的BroadcastReceiver这样做的任何意图,或者是有其他的方法来做到这一点?

I would like to check if bluetooth is enabled on any Android device periodically. Is there any intents that I could catch using BroadcastReceiver to do so, or is there other ways to do it?

推荐答案

你去那里:

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
    // Device does not support Bluetooth
} else {
    if (!mBluetoothAdapter.isEnabled()) {
        // Bluetooth is not enable :)
    }
}

使用使用-许可

 <uses-permission android:name="android.permission.BLUETOOTH" />