I'm trying to get a good position via android and GNSS. The locationManager of Android gives me in every Case only one update per second. So i decided to switch to the GoogleFusedApi and the FusedLocationProviderClient to get my current position more often.
I tried different use cases and had different results:
Going down the street:
Update between 200ms and 1000ms => Average: 450ms
Driving same route with the bike:
Update between 300ms and 1000ms BUT Average: 840ms
I don't get why i get less updates if my speed is much higher. In both cases the smartphone was in my pocket.
The important snippet of my code:
private FusedLocationProviderClient mFusedLocationClient;
private LocationRequest locationRequest;
private LocationCallback locationCallback;
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
locationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, 0)
.setWaitForAccurateLocation(false)
.setMinUpdateIntervalMillis(0)
.setMaxUpdateDelayMillis(0)
.build();
locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
if (locationResult == null) {
return;
}
location = locationResult.getLastLocation();
}
};
private void getLocation() {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
}
mFusedLocationClient.requestLocationUpdates(locationRequest, locationCallback, null);
}
Maybe i did something wrong with the locationRequestSetup or something else? I hope anyone could help me to get the updates on Bike as fast as while walking.. Or could explain why i get the position more often while walking..
Is there any other soloution to get the Position with an average about 500ms in Android?
THANKS FOR HELPING!