I am working on an app that has geofencing features, using the Google Play Services APIs.
It works pretty well in general, except I frequently receive "false positives", meaning I receive EXIT events quickly followed by ENTER events, even when the device is actually inside the geofence and didn't move.
The situation improved a bit when I started listening to DWELL events instead of ENTER (with a loitering time of 3 minutes). I use a radius of 100m for the fences.
But when doing this, I still receive the incorrect EXIT events. Ideally I would love to have the equivalent of the loitering time, but for EXIT events (the ability to be notified of EXIT events only if the device has been seen out of the fence at least for x minutes). I think this would solve the problem; unfortunately the API doesn't have such feature.
Is this problem a common one, and what can be done to resolve it?
The problem occurs when determening the current geo-location depends on the cell-phone-towers where your cellphone is connected to. if your phone switches the cell-towers and these are far away from each other the google serverice assumes that you have moved.
I have solved a similar problem by introducing a time delay before reacting to event:
A timer is cleared (if active) and then started if an event occurs.
the eventhandling is done when the timer event occurs and only if the new event state is different from the previos event state
Example: if your timer has a delay of 5 minutes all event changes below the delay time will be ignored. if previos timer event was enter and new timer event is enter do nothing.