FusedLocationClient not calling onLocationResult
Before requesting location updates, your app must connect to location services and make a location request. Some thing like this:
private static LocationRequest createLocationRequest() {
LogHelper.trace("createLocationRequest");
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(200000);
mLocationRequest.setFastestInterval(300000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
return mLocationRequest;
}
public static void checkLocationService(final Fragment fragment, final FusedLocationProviderClient client, final OnSuccessListener<LocationSettingsResponse> successListener, OnFailureListener failureListener) {
LogHelper.trace("checkLocationService");
final LocationRequest request = createLocationRequest();
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder()
.addLocationRequest(request);
SettingsClient settingsClient = LocationServices.getSettingsClient(fragment.getActivity());
Task<LocationSettingsResponse> task = settingsClient.checkLocationSettings(builder.build());
task.addOnSuccessListener(fragment.getActivity(), new OnSuccessListener<LocationSettingsResponse>() {
@Override
public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
LogHelper.trace("onSuccess");
startLocationService(client, request, new LocationCallback());
successListener.onSuccess(locationSettingsResponse);
}
});
task.addOnFailureListener(fragment.getActivity(), failureListener);
}
try to active/desactive location from android settings.