I am requesting permission for ACCESS_FINE_LOCATION in an Activity which makes no sense unless the user approves this permission, so if the user denies this I am closing down the Activity. The problem is that once the user denies the request with the "Never ask again" option selected, I don't know how to reset that state and ask again in the future if the user changes her mind.
private void loadLocPredictions() {
//ToDo clean the permission thingy up.
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
PERMISSIONS_REQUEST_FINE_LOCACTION);
return;
}
// Do stuff...
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case PERMISSIONS_REQUEST_FINE_LOCACTION: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
loadLocPredictions();
} else {
finish();
}
return;
}
}
}
Thanks for any help in advance. I am probably missing something trivial here, or just a coffee. Feel free to downvote me if that's the case.