Android notification when BLE device is detected

We are working on an Android application that connects GATT to BLE devices and records some characteristics. Our current approach is to scan devices every few seconds (startLEScan on Android 4.3 and 4.4. Devices and launch on Android 5.0+) and connect to the device when found.

This solution works, but it drains a lot of battery because we need to keep tracking locks (or run the alarm manager every few seconds) for the scan to work when the phone is asleep.

Is there a way that Android can notify an app when a BLE device is detected, rather than constantly scanning for devices?

The iOS app works great because iOS wakes up the app in the background when there is some BLE device nearby, which saves a lot of battery. Surprisingly, there is something similar on Android to keep the battery at an acceptable level.

For reference, we also tried the Alt-Beacon library , but found that it internally uses an alarm manager, and if we configure an alarm manager every three seconds, it consumes 7-8% of the battery every hour.

+3


source to share





All Articles