Search code examples
androidgeofencingandroid-geofenceandroid-8.0-oreo

Android 8 Geofences on killed app


With the transition to android 8 I encountered an issue that geofences in app are not working anymore when app is killed.

I implemented geofences as per android developers guide, so no reason to show any code snipplets.

With some small modifications and explicit broadcast receiver I was able to receive geofence notification when app was running and when app was in background.

Still no luck with case when app is killed. If anyone had made transition to android 8 and has working geofences please share your experience.


Solution

  • You will have to change the PendingIntent that the geofence triggers to a BroadcastReceiver instead of a Service. The system will no longer let a Service start when your app is in the background.

    Also noted in this answer.