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();
}
});
I'm facing this problem and find out this problem cause by Location mode, even though GPS turn on but if Location mode still select "GPS only" will make this exception occur, when i change to another mode, it work fine. Unfortunately you can't set the location mode programmatically but you can send the user directly to the settings screen where he can do that, follow this anwser https://stackoverflow.com/a/25745124/8921450
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With