I'm creating a location client at the moment, currently i have
public void startUpdatingLocationProcess(Context context) {
parentContext = context;
if (mFusedLocationClient == null){
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(parentContext);
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(5000);
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
if (ContextCompat.checkSelfPermission(parentContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
{
mFusedLocationClient.requestLocationUpdates(mLocationRequest, new LocationCallback(){
@Override
public void onLocationResult(LocationResult locationResult) {
onLocationChanged(locationResult.getLastLocation());
}
} , Looper.myLooper());
}
}
This is in a LocationApi class that i want to run throughout the applications lifecycle, this particular app runs many activities so i don't want to "recreate" the request every time i destroy and create a new activity.
The permission for FINE_LOCATION is allowed and checked, there are no errors in the logcat and the code runs the requestLocationUpdates method on creation of the mFusedLocationClient object, but it never calls the "onLocationResult" method.
Is there something i'm missing with using this api?