Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RESOLUTION_REQUIRED even if user's location is on. Is it possible?

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();
                }
            });
like image 922
Juan Carlos Durini Avatar asked Mar 02 '18 17:03

Juan Carlos Durini


1 Answers

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

GPS mode picture

like image 104
manhtuan21 Avatar answered Sep 22 '22 13:09

manhtuan21