I'm trying to work with geofences in my application. So far I have succeeded and it works perfectly when the application is in foreground. I'm checking with Android Emulator which have google play services. To check this I'm setting the location parameters and as I said it works fine when the application is on foreground.
But when the application is on background it seems that the transitions are not triggered, until I open the application or open Google Maps application.
So I've tried to use BroadcastReceiver instead of IntentService and I've registered the broadcastreceiver in the manifest file Like this:
<receiver android:name = ".GeofenceReceiver"
android:exported = "true"
android:enabled = "true"
/>
But I'm still having the same results..
So how can I trigger the Geofence transitions when the application is on background?
I thought about using LocationServices.FusedLocationApi.requestLocationUpdates
inside a Service. So with this approach my application will ask for location
updates and this probably will trigger the geofence transition.
But probably it will consume battery and this is a bad practice. So, are there any other options?