0

I am using Google's fusedlocationproviderclient to track location of user in real time on android using a foreground service. I have noticed some times fusedlocationproviderclient returns same locations multiple times in a row. As of now I am observing, sometimes fusedlocationproviderclient return very inaccurate location (Around 700m).

Earlier I used to track location using Location_Services but moved to fusedlocationproviderclient in order to reduce battery consumption. I have set fusedlocationproviderclient priority to High Accuracy. I have set minDisplacement to 100m.

This is my location object

private void createLocationRequest() {
    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(10000);
    mLocationRequest.setFastestInterval(10000);
    mLocationRequest.setSmallestDisplacement(100);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}

I am expecting it should return accurate locations. As I display tracked locations onto a static map die to incorrect location a straight line appears in map.

onkar vhatkar
  • 46
  • 2
  • 8
  • I am just starting down this path with FusedLocationProviderClient. But it seems that if you want more accurate results, then play with your LocationRequest settings. Create a test app that allows you to change these settings dynamically. I have found that in a foreground app, Interval=1000 and FastestInterval=500, produces best-ish results. Also smallest displacement of about 20m. In either case, and for whatever reasons, changing these parameters changes the accuracy of the location returned in the Callback. – JJJones_3860 Apr 02 '20 at 14:56

1 Answers1

0

I would check the type of location permission you're setting in your Manifest.

You have 2 available:

ACCESS_COARSE_LOCATION - This will allow you to access an approximate location

ACCESS_FINE_LOCATION - This one will allow you to access a precise one, which I believe is what you want in your case.

Norik
  • 161
  • 1
  • 9
  • Yes, I do have both the permissions added in the Manifest file. – onkar vhatkar Jun 04 '19 at 09:32
  • Have you tried removing the ACCESS_COARSE_LOCATION? There's no need to add both and if you want your location to be as precise as possible, I would only add ACCESS_FINE_LOCATION. – Norik Jun 05 '19 at 13:03