0

My app use Google Play service API to get the user location and check if the device is inside or outside a particular area of 50 mt of radius. The app use PRIORITY_HIGH_ACCURACY and a Interval of 1 minute. So I create GoogleApiClient:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    mGoogleApiClient.connect();

In the onConnected callback:

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(60000);
    mLocationRequest.setFastestInterval(10000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

and

MyLocationListener.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, mLocationListener);

My app also filter locations based on accuracy (if accuracy > 200 mt I discard it) and time (if it is too old I discard it).

The app works fine except in some particular areas where sometimes it returns wrong locations update about 500 meters from the real location, and those wrong locations are always near the same place, some step away from a Cell Tower.

In those areas I get a combination of wrong and correct locations and my app think that the device is sometimes inside and sometimes outside the area of interest.

When I get a location update I wait for other 3 in a row to confirm the position. Also I filter location if exactly the same as the previous. This means that when I m getting those errors I'm receiving 4 wrong locations in a row each one slightly different from the others.

Is there a way to prevent this behavior? Can this be caused by the Cell Tower?

AleCat83
  • 1,443
  • 3
  • 22
  • 41

2 Answers2

1

There's always a chance of it being wrong. An accuracy of 200m doesn't mean its within 200m- it means there's a 67% chance you're within 200m. There's still a 1/3 chance you aren't.

Since most of the Google Play location providers are fused (use GPS and wifi/cell data), yes being very close to a tower could screw with the data.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • So, since with the google place apis is not possible to filter the cell provider, it would be best to use the old location apis and listen only the to the gps provider (if it is not matter of battery)? – AleCat83 Jan 29 '16 at 22:50
  • You'd still have occasional blips, but it might be more accurate. Cell towers wouldn't effect it. You can try it and see if it performs better. You could also try filtering the existing locations (you already filter out low accuracy ones. You could also filter out large jumps, or at least large jumps that aren't confirmed by the next update). – Gabe Sechan Jan 29 '16 at 22:53
  • actually when I get a location update I wait for other 3 in a row to confirm the position. Also I filter location if exactly the same as the previous. This means that when I m getting those errors I'm getting 4 wrong locations in a row each one slightly different from the others. – AleCat83 Jan 29 '16 at 22:58
  • Interesting. It might be either the cell tower screwing up readings, or Google having the cell tower in the wrong place. Trying pure GPS would be at least a good debugging step. – Gabe Sechan Jan 29 '16 at 23:24
  • I will try and post the results. So the only way to get GPS only location is using the old android location api right? With google place service you can get only fused provider. – AleCat83 Jan 30 '16 at 16:17
0

Change setInterval(60000) to setInterval(20000) or to 5000.

Since the interval is one minute, you won't get updates even if the user moves. That's why there is an inaccuracy.

According to Google, setInterval(long) means - set the interval in which you want to get locations. setFastestInterval(long) means - if a location is available sooner you can get it (i.e. another app is using the location services. Means, if no other apps are using the location service, you will get updates only after a minute).

Msp
  • 2,493
  • 2
  • 20
  • 34
  • I already tried some interval combinations but it won't solve the problem. If the device is still in the middle of my area of interest it get some (the most) locations near the true location and sometimes (few) it get locations near the Cell Tower even if it do not move for hours. – AleCat83 Jan 29 '16 at 22:48