I face todays a problem with a fresh mobile. when i do :
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(150000);
mLocationRequest.setFastestInterval(30000);
mLocationRequest.setMaxWaitTime(900000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
mLocationRequest.setSmallestDisplacement(25);
Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if (location == null) { Log.w(TAG, "getLastLocation return null"); }
else { onLocationChanged(location); }
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, this);
The problem is that LocationServices.FusedLocationApi.getLastLocation
return null. normally this is not a big problem as we also setup requestLocationUpdates
. BUT the problem is that requestLocationUpdates take a very long time to return. How can i say to requestLocationUpdates
to return the fastest as possible the First location, and to return the following location at interval like we configured the mLocationRequest
?