2015-11-30 141 views
-2

我想每隔10分鐘左右在背景中持續進行一次BLE掃描。但大多數用戶在那裏關閉了藍牙。有什麼辦法可以解決這個問題嗎?我們可以對等維護和關閉BLE如何在Android中執行背景BLE掃描?

回答

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