4

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
elgorbo
  • 131
  • 1
  • 8
  • 1
    elgorbo -- Did you ever find an answer to this problem? I've had similar experience with occasional false exits with Google Play Services geofences. I think it's related to the phone momentarily losing wifi. – TonyC Apr 07 '15 at 20:07
  • I never got anything concrete. Pretty sure it happens whenever play services finds that location accuracy drops to the point that it can't tell if you are inside or out of the geofence. That's probably going to happen whenever any connection drops out. – elgorbo Apr 09 '15 at 21:23
  • 1
    Random geofencing exit events happen when gps signals get disturbed and/or lost (e.g. indoors, in your office) then the phone fallbacks on cell signal but cell location is inaccurate so you have the "occasional false exits". – Gabor May 20 '16 at 21:17
  • @Gabor I'm getting exit even after entry event in few seconds I'm not went out of the region . and if i open google maps it is showing 15km away from my current location. what is the problem ? pls reply – k_kumar Jul 04 '19 at 06:01

2 Answers2

0

First of all I'm not a developer. I used AutoLocation + Tasker on my Nexus 4 running Android 4.3 with 100% satisfaction. Instant, accurate and repeatable. I got a new Nexus 5 back in Nov 2013 and couldn't get this app to work at all. I experienced the exact symptoms plus more. I have to be inside the geofence for 15 to 20 minutes before it recognizes that I'm inside and many time during the day while I was inside, it will trigger exits.

I waited for Android update 4.4.1 then 4.4.2. I waited for Google Play Service 4.1 now 4.2. Nothing works. I tried another geofence app called Geofence Memo which uses the same API and same problem.

I even bought a new Red Nexus 5 that comes with the latest software and same problem.

I should mention that my old Nexus 4 is now running Android 4.4 and this AutoLocation + Tasker works like a charm.

When I was still using my Nexus 4 on 4.3, I ran a hybrid modem which enabled LTE and this app combo stopped working until I reflashed the factory modem zip.

I think it has to do with a baseband bug more than an Android bug but I could be wrong.

My 2 Nexus 5's run 100% stock rom without rooting.

More, I had my phone screen on while entering and existing the geofence thinking it may be a background process issue and it totally missed it. I even tried running GPS navigation through the geofence and it still had no clue where I was.

Powergrep
  • 1
  • 1
0

As mentioned in the comment by TonyC & Gabor

I think it's related to the phone momentarily losing wifi. – TonyC

I too faced the similar issue, and as observed, it is related to the network issue.

So the solution for this is wherever we are using GeofencingEvent which has some code related to exit and entry of geofence,just check the network availability as well.

GeofencingEvent geoFenceEvent = GeofencingEvent.fromIntent(intent);
    boolean isNetworkAvailable = CommonUtils.isNetworkAvailable(getApplicationContext());
    if (geoFenceEvent.hasError() || !isNetworkAvailable) {
        int errorCode = geoFenceEvent.getErrorCode();
        Log.e(TAG, "Location Services error: " + errorCode);
    } else{ // your code here}
SimplyProgrammer
  • 1,799
  • 2
  • 17
  • 28