android / location-samples

Multiple samples showing the best practices in location APIs on Android.
Apache License 2.0
2.71k stars 2.77k forks source link

Very long time between Geofence BroadcastReceiver trigger and Job execution #168

Open mournblade opened 6 years ago

mournblade commented 6 years ago

We have the need to do a network call very soon after geofence is triggered. However, when we run your example with some debugging added, we see that there is often long time passing between the job being enqueued by the receiver and it being executed by the jobintentservice. Often 5-10 minutes, sometimes 30 minutes or more. Our record is 90 minutes I think, on a Galaxy S9!

Is there anything that can be done so that the Job is executed directly after the trigger?

(We tried doing all in the BroadcastReceiver with goAsync() but the network call sometimes seem to be prohibited, we suspect it has something to do with Doze mode...)

mudassirzulfiqar commented 5 years ago

@mournblade Hi , have you found the solution of your problem, I have been struggling to solve this problem too, I also immediately need to communicate with the server right after the geoFence, My geoFence get triggers with delay, Even in doze mode it takes 50 minutes, I dont understand If Doze mode is here then what is the purpose of GeoFence API if in the end user cant get notified about the event?

ben-j69 commented 5 years ago

I am facing the same problem

mudassirzulfiqar commented 5 years ago

@ben-j69 Can you explain little bit about your problem

ben-j69 commented 5 years ago

I coded the geofencing like in the doc. It is working perfectly if my app follow the position or if I open google maps. If not app is launched the geofencing does not work.

mudassirzulfiqar commented 5 years ago

did you follow the exactly the same code as in this Repo ?