Android Question [SOLVED] Removing "Don't ask again" option from access dialogue box

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I'm using this line to make sure the user has permission to get the devices location when the user first installs the app.

B4X:
            Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)

It calls a dialogue box asking for access to the devices location. If the user taps "Deny" and starts up the app again, the same dialogue box is shown but this time it gives the user the option "Don't ask again". How do I stop "Don't ask again" from showing up on the dialogue box? I ask because some of my users are tapping "Don't ask again" and calling me up and I have to tell them they need to go to the app manager to allow the permission.

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
How do I stop "Don't ask again" from showing up on the dialogue box?
you can´t. It is the decission of the user to use it (or not). This is how android works.

If you are still not getting permission then you can inform the user about this and ask him to change the permission for your app in his device.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Don,

Is there a way for me to find out if the user ticked the "Don't ask me again" checkbox? If I can set up a handler for that, then I can remind the user to set permission on the GPS before running the app.

Here's the code I'm using.

B4X:
Public Sub StartUpTheGPS

    ' Make sure there is permission to use the GPS and start it up if it's enabled.
    '------------------------------------------------------------------------------
    Try
        If Starter.GPS1.GPSEnabled = False Then

            Msgbox("My message is here.")

            StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
        Else

            Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
        End If
        
    Catch
    End Try
End Sub

B4X:
Sub Activity_PermissionResult (permission As String, Result As Boolean)

    ' If there is permission to use the GPS then start it.
    '-----------------------------------------------------
    If permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
        If Result Then
            CallSub(Starter, "StartGPS")
        Else
            Msgbox("My message is here.")
        End If
    End If
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Is there a way for me to find out if the user ticked the "Don't ask me again" checkbox?
i don´t know
You can check for the permission; if not getting a success then you do not have the permission. Decide by yourself to show anything to the user that he need to give this permission.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Android offers shouldShowRequestPermissionRationale function.
Take a look discussions, for example, https://stackoverflow.com/questions...stpermissionrationale-not-working-as-expected and samples, for example, https://www.programcreek.com/java-a...t&method=shouldShowRequestPermissionRationale


shouldShowRequestPermissionRationale
added in version 24.1.0

boolean shouldShowRequestPermissionRationale (Activity activity, String permission)

Gets whether you should show UI with rationale for requesting a permission. You should do this only if you do not have the permission and the context in which the permission is requested does not clearly communicate to the user what would be the benefit from granting this permission.

For example, if you write a camera app, requesting the camera permission would be expected by the user and no rationale for why it is requested is needed. If however, the app needs location for tagging photos then a non-tech savvy user may wonder how location is related to taking photos. In this case you may choose to show UI with rationale of requesting this permission.
 
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Thanks for the replies. I'll code around it then and make sure the user gets the appropriate messages.
 
Upvote 0
Top