I'm making an application that times how long you stay inside a geofence. A timestamp is taken when the entry event is detected and it is compared to a timestamp taken when the exit event is received.
This worked fine with my Galaxy Nexus during the summer, but starting in November (2013) I noticed some odd behaviour starting. I had just started using a new Nexus 5 as my test device and I was now finding exit events being sent while I was still well inside the geofence. The geofence is 1500m and I logged my last known location when the exit event comes in and it is well inside the exit zone.
There seems to be a correlation to the events and my device being asleep and also being turned back on, but I'm unable to really prove much about why this is happening. My theory is that maybe the accuracy of the location degrades so that Play Services can't confirm that I'm inside the zone anymore and triggers an exit event. When my device turns back on and updates its location using network/wifi/gps, it triggers a new entry event. It should also be noted that I sometimes lose cell reception in my office when my phone is in my pocket while I'm in certain meeting rooms.
I tested the idea of ignoring an exit event when the last known location is within the geofence, but I found that this would cause many proper exit events from working properly. Requesting a location update usually fails since I'm inside and the update usually times out (trying for about 2 - 4 minutes). Also, once the exit event is sent, I would get a new entry event at some random time later since Google Play has determined that I was outside the zone and now am found back inside.
Has anyone seen similar behaviour or has an explanation on why this occurs? There doesn't appear to be much I can do about this since the geofence is added and working properly, but I can't trust that exit events are legit all the time which puts my time measurements in doubt.