如何检查是否已启用蓝牙编程? [英] How to check if bluetooth is enabled programmatically?

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

问题描述

我要检查,如果蓝牙技术是在任何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" />

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆