简体   繁体   中英

Android Geofencing: frequent incorrect EXIT/ENTER events whereas device is actually stationary in fence

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.

I have experienced a similar issue. I am currently experimenting with several solution. One is using https://pathsense.com . The other is to filter out geofence event base on the accuracy of the triggering location. According to k3b's theory, the geofence event is triggered because of cell tower-based location. If that's true, I believe that the uncertainty will be high because a single cell tower has something like a 1 mile radius. It could also be disproved if you set your Location Mode to Sensor Only, that way it only uses the GPS for data.

I have yet to conclude anything from my test so far. Using the filtering that I mentioned, I have been able to reduce false-positives by approximately 80%, but it still happens on a daily basis, which is unacceptable as a consumer app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM