如何在android中执行后台BLE扫描



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

从文档中,用户必须自己启用它,尽管您可以这样提示他们启用它:

// 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);
}

最新更新