I want to request for the permission android.permission.ACCESS_COARSE_LOCATION for getting tower location.
But before requesting for that permission, i want to know whether it is blocked by the user by checking "Never ask again" check box.
Is there a proper way to know "Never ask again" for a permission?
=======================Requirement==========================
I want to prevent user from entering the screen without granting location access permission.
So I am using the permission request as a function named requestLocation() which is called in onResume().
Inside requestLocation()
-> Check for permission
-> If : permission already granted, register update location.
-> ELSE : not granted, show dialogue for grant permission with two button
-> One button execute the code "ActivityCompat.requestPermissions(..........);" and showing the in-built pop up for permission.
-> Another button helps to exit from the application.
When deny or grant is flagged in onRequestPermissionsResult(), then requestLocation() will executed again.
But in the case when "Never show again" is checked and deny is clicked, the infinite loop will continue as like the following
onRequestPermissionsResult()=>
PERMISSION_DENIED =>
requestLocation()=>
Permission not granted =>
ActivityCompat.requestPermissions(..........); =>
onRequestPermissionsResult() => PERMISSION_DENIED =>requestLocation()=>
Permission not granted =>
ActivityCompat.requestPermissions(..........);
=>...............
So if I can understand whether "Never show again" is clicked or not, I can exit from the loop by checking it inside requestLocation().
If:
checkSelfPermission()
indicates that it is denied), andshouldShowRequestPermissionRationale()
returns false
then the user has checked "never ask again".
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