Maxim Firsoff
Maxim Firsoff

Reputation: 2296

Implement a service to stay alive permanently for detecting BLE controllers on Android?

I have an access system based on BLE controllers and a cloud service. We're going to implement the "hands-free" mode for getting access to the restricted area. It means:

My thoughts:

Plan 'A' is using a combination of

  1. Foreground service (working in the active mode)
  2. FCM high-priority messaging (waking up in the Doze Mode)

Plan 'B' is using the white-list apps of Android to prevent battery optimisation in the Doze mode.

Upvotes: -1

Views: 190

Answers (1)

Emil
Emil

Reputation: 18497

You don't need the app to stay alive if you just want to perform a background BLE scan. Just use the PendingIntent BLE scan feature https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner#startScan(java.util.List%3Candroid.bluetooth.le.ScanFilter%3E,%20android.bluetooth.le.ScanSettings,%20android.app.PendingIntent). Then your app process will be started when an advertisement packet matching your filter arrives.

Upvotes: 0

Related Questions