I'm using Google's SettingsClient
on an app. It works fine, but there are some users that are not able to use GPS, even if they have location turned on and they had already granted access to location permission. For what I understand, if Settings Client
returns RESOLUTION_REQUIRED on it's FailureListener
, it's because user has location disabled.
Is that true? or is there any other reason RESOLUTION_REQUIRED is returned?
When RESOLUTION_REQUIRED is returned, GPS icon is not shown on status bar, but it should be there!
This is my code:
SettingsClient mSettingsClient =
LocationServices.getSettingsClient(context);
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(UPDATE_INTERVAL_MS);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL_MS);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
LocationSettingsRequest.Builder builder = new
LocationSettingsRequest.Builder();
builder.addLocationRequest(mLocationRequest);
mLocationSettingsRequest = builder.build();
mSettingsClient.checkLocationSettings(mLocationSettingsRequest)
.addOnSuccessListener(new OnSuccessListener<LocationSettingsResponse>() {
@Override
public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
connected = true;
// Fused Location code...
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
connected = false;
gpsFailureMessage = e.getMessage();
}
});