Monitoring Estimote Beacons even if the app is closed

Hi,
I work on an app and I need to monitor Estimote Beacons even when my app is closed. It aldready works when it is in background thanks to the BeaconServie and BeaconManager. Is it possible to make the BeaconService persistent ?
Thanks !

I find the answer of my issue, we can’t monitor Estimote Beacons on Android if the app is not at least in background …

I don’t think this is possible.

Yes, monitoring in the background works on Android. But, unlike on iOS, it will not work if the app has been shut down completely (removed from the app switcher).

How did you get monitoring in background to work?
It’s not working with my code, when i minimize the app or put the phone to idle, the monitoring stops.

Regards

Hi Thomas,

monitoring in the background or while phone is locked works for me too. I have used the default android example from estimote. Even the estimote demo when trying notification demo works this way for me.

best regards

Is is possible to make the monitoring work in the background even when the application is closed or the phone is rebooted. The trick is to make a service that keeps checking for the beacons. A service can run in the background even when the app itself is killed.

I advice to start the process of searching for beacons with Geofencing, because if you keep searching for beacons, the users battery will be drained very quickly.

Yes, this is exactly what I’ve done and it works fine ! It seems that returning START_STICKY in the onStartCommand() of the service makes the service restart when the app is killed … Looks good but I don’t now if it’s the best way to do… If you have any other suggestions to make a service run even if the app is killed it’d be great !

1 Like

The method you used is a way to make sure a background service is constantly checking if there are beacons. You do not want to do that, because of battery/memory drain etc. I suggest only (re)starting the service if you are within a Geofence. More on Geofencing can be found here: https://developer.android.com/training/location/geofencing.html

START_STICKY only restart your service when it killed by OS ( as i read ), but when your app is kill from task service is stopped…

the only way i can make app stil running in the background is Remove app from task, app is stil running even user clear all Task in android ( no the best way )

and i create alarmManager to handle it

  1. for start & configure beaconManager
  2. for checking my service is running or not.

but my BeaconService is stopMonitoring when phone locked,

@Michal_Hrezdovic hi, is your BeaconService/BeaconManager is really working when phone locked ? because in my case when i’m lock my phone beaconService+BluetoothAdapter is stop produce the log in logCat.

I really don’t understand why you guys at Estimote don’t offer a full example how to monitor for beacons in the background even when the app is killed. This task is generic and a must for every application using your beacons.

2 Likes

I agree, but the problem is that you have to implement it differently in different cases. You cannot simply always scan in the background, because that will leave a service that drains memory and battery life. If just one app on the phone does this, there is no problem, but if everyone uses this technique to always scan for beacons, you’ll have 20+ apps scanning all the time, massivly draining your battery.

Showing how you can do it is a good option, but it is recommended to use another trigger to start the background search, such as a geofence, a timespan, movement, or something else.

1 Like

hi @Michal_Hrezdovic
Is your mobile application native? If so, what is your API version?