Geofencing API triggers enter event when already in zone

Niko picture Niko · Jul 1, 2013 · Viewed 7.2k times · Source

I've encountered this problem with the latest Android Geofence API. The usage is exact to the example usage. I set Geofence.GEOFENCE_TRANSITION_ENTER type geofence with 500m radius and expiration is Geofence.NEVER_EXPIRE. This works ok, but if I'm about 10 meters to latitude longitude and I set the geofence, it triggers immediately.

So am I understanding the term Geofence.GEOFENCE_TRANSITION_ENTER wrong here, shouldn't it trigger only when we are outside the zone and enter it, not when we are already in the zone?

Thanks.

Answer

flx picture flx · Sep 2, 2013

Well, think of Geofences of 3D objects: 2 dimensions in space, one dimension in time. Between the checks, if a Geofence was hit, your new fence got moved into place.

However, I just save the timestamp on adding fences and ignore all hits within seconds after that.