如何在android中执行背景BLE扫描?

时间:2015-11-30 11:09:34

标签: android bluetooth-lowenergy

我想每10分钟左右连续进行背景BLE扫描。但大多数用户都关闭了蓝牙。有什么方法可以解决这个问题吗?我们可以打开和关闭BLE

1 个答案:

答案 0 :(得分:1)

docs开始,用户必须自己启用它,但您可以提示他们启用它:

// Ensures Bluetooth is available on the device and it is enabled. If not,
// displays a dialog requesting user permission to enable Bluetooth.
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}