I'm using the FusedLocationProviderClient in a project. At the onCreate method I've got this snippet being called:
private void setupFusedLocationProvider() {
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
LocationRequest locationRequest = new LocationRequest();
locationRequest.setInterval(10000);
locationRequest.setFastestInterval(5000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
builder.addLocationRequest(locationRequest);
builder.setAlwaysShow(true);
SettingsClient client = LocationServices.getSettingsClient(this);
Task<LocationSettingsResponse> task = client.checkLocationSettings(builder.build());
task.addOnSuccessListener(this, locationSettingsResponse -> locationPermissionsSatisfied());
task.addOnFailureListener(this, e -> {
if (e instanceof ResolvableApiException) {
try {
ResolvableApiException resolvable = (ResolvableApiException) e;
resolvable.startResolutionForResult(Activity.this,
REQUEST_CHECK_LOCATION_SETTINGS);
} catch (IntentSender.SendIntentException sendEx) {
//Ignore
}
}
});
}
The problem is that, even with a cache wipe or uninstall, the app does not show a dialog to request for proper location permissions settings: the onSuccessListener is being called everytime (while the location premissions are not set). I'm using the latest google services apis.
My manifest contains these 2:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />