0

We are using FusedLocationProviderClient to fetch GPS location continuously in our app. We find that the location provided is slightly off (about 200mtrs) and delayed by about 15-20secs. This causes problems while driving.

The code snippet is below. Please let me know what we might be doing wrong, appreciate your help to fix this. If there is a better method to fetch location continuously, please suggest that as well.

mFusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
locationRequest = LocationRequest.create();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setInterval(500);
locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {

    if (locationResult == null) {
    return;
    }
    Location location = locationResult.getLocations().get(locationResult.getLocations().size() - 1);
    if (location != null) {
    currLatFusedLoc = location.getLatitude();
    currLngFusedLoc = location.getLongitude();
    }
};
};

mFusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, Looper.myLooper());

0 Answers0