本文介绍了如何以编程方式检查蓝牙是否已启用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想定期检查是否在任何 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 enabled :)
} else {
    // Bluetooth is enabled
}

使用 uses-permission

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

这篇关于如何以编程方式检查蓝牙是否已启用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:52