0

I'm implementing Geo-fences. It works quite well, but their transition events only get trigger when the app is in background or foreground. I have an IntentService that receives the geo-fences transitions events, but my problem is that this intent service only receives updates if the app is running.

The implementation has an standard LocationService for managing the geo-fences by the app when is running, then an IntentService that gets notified by the OS when a geo-fence transition is detected.

Have you got any solution to receive transitions even when the app is not running at all?

Thank you.

Juampa
  • 2,035
  • 2
  • 25
  • 35

2 Answers2

1

Intent service is supposed to start a worker thread, process whatever you plan it to do and then close itself. In your case when the app is running the service basically spawns, does work and then shuts itself down.

From the android docs

the service is started as needed, handles each Intent in turn using a worker thread, and stops itself when it runs out of work.

To solve this you might want to create your own service implementation via extending the Service class.

Checkout diff between Intent Service and Service

P.S : If you provided some code which you have tried one can directly show you whats exactly is not making your code run when the app is not running.

Community
  • 1
  • 1
Nishant Srivastava
  • 4,723
  • 2
  • 24
  • 35
0

I found a solution as per official documentation.

The recommended min radius should be between 100 to 150 metres, specially if you are using PRIORITY_LOW_POWER or PRIORITY_BALANCED_POWER_ACCURACY in your location request.

The issue I had was that I was saving the geo-fences to the device with a very small radius (e.g 20 metres) in which case the device didn't detect the geo-fence transition events at all when the app is not running (not in background and foreground).

Juampa
  • 2,035
  • 2
  • 25
  • 35