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

如何在android中执行背景扫描?,android,bluetooth-lowenergy,Android,Bluetooth Lowenergy,我想每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 (mBluetoothAd

我想每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);
}