Android-Proximity-SDK
Android-Proximity-SDK copied to clipboard
Restore foreground service after reboot
Prerequisites
- [x] Put an X between the brackets on this line if you have done all of the following:
- My beacons have Estimote Monitoring enabled (Check it in the Estimote Cloud, or via app)
- My Android device/devices supports BLE and has Android OS version >= 5.0.0
- My Android device/devices have bluetooth enabled
- My app has Location Permissions granted
Basic information
Estimote SDK version: 0.3.3
Android devices affected: Samsung Galaxy S7
Android OS version affected: all
Beacon hardware version: F3.3
Description
As I already have when I monitor Geofence areas, I need to have the same behavior for Beacons.
Steps to reproduce:
- Register background scan service with Foreground Service
- Reboot your phone
- No more background scan
Expected behavior: The background scan is restored after booting up.
Additional information
As stated in the official guidelines, "silent bluetooth scan" is not allowed. But if you create a class that extends BroadcastReceiver, it might be possible to restore the previously created persistent notification. By doing so, it doesn't seem to be in contradiction with the guidelines.
Can I do by myself with latest SDK? I think it's a little different than the use case described with ProximityTrigger for Android 8.0 Oreo. I don't want to trigger when the app is killed, I "just" want the service to be reactivated.
Hey @MBach
ProximityTrigger is wrapping the ugly Android API for launching the scan with your PendingIntent instead of a callback object. There are two options to use ProximityTrigger in our SDK:
- A ready-made
displayNotificationWhenInProximity(notification: Notification)that registers a broadcast receiver under the hood. When a pending intent gets triggered by the scan, the BR will display the given notification. triggerPendingIntentWhenInProximity(pendingIntent: PendingIntent)which let's you manually create pending intent and control it.
The problem with scanning after rebooting is that the registered startScan callbacks/pendingIntents (through Android API) are flushed, so you won't get any results back afterwards, so your BR won't be triggered.
The one idea is to register a BR for the boot events and then launch our ProximityTrigger there.
Unfortunately, from my experience it's impossible to call startScan(...) from the background successfully. You need to have your app in the foreground.
Second solution is to register a BR for boot events and then launch our ProximityObserver in the foreground service there. But I need to validate if this is possible, cause I'm not 100% sure.
I can't look deeper in this case right now, because I want to keep up with our sprint schedule. I will add this to my backlog anyway :)
Regards, Paweł
Ok thanks for your response. Currently, I also don't have the time to implement my own Broadcast Receiver, but I'll try in the next weeks.
Hi @pawelDylag, Do you have some new informations on this question?
me too facing the same issue....is there any solution?