Android Question RuntimePermissions

Robert Valentino

Well-Known Member
Licensed User
RuntimePermissions has Check and CheckAndRequest functions but I believe it needs a third and that is Request.

If the user has been asked once and denied and then asked again and denied and checks the Don't ask again there is NO way to ask them again should they change their mind

MarkusR pointed me to shouldShowRequestPermissionRationale https://www.b4x.com/android/forum/threads/permissions-dont-ask-again.95414/#post-602929

But that only helps half way. What I feel is needed is a RequestPermission that just requests without checking

Erel any chance of getting RequestPermission in library?
 

DonManfred

Expert
Licensed User
It is recommended to always use checkandrequest
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
I am sure it is.

But explain to me how you handle the case where the user has selected Don't Ask Again and Deny and NOW wants to allow the function

How can I ask again. CheckAndRequest won't ask the question again
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
i believe the idea of shouldShowRequestPermissionRationale was if the app have not his permissions, showing the user a explanation in any form.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
I don't believe that will ask the question again. Or at least not how I see it in stackoverflow
https://stackoverflow.com/questions...stpermissionrationale-not-working-as-expected
https://stackoverflow.com/questions...rmissionrationale-return-false-the-first-time

It still seems you need a RequestPermission

B4X:
private void requestcontactsPermission() {

       if (ActivityCompat.shouldShowRequestPermissionRationale(this, android.Manifest.permission.READ_CONTACTS)) {
           //If the user has denied the permission previously your code will come to this block
           //Here you can explain why you need this permission
           //Explain here why you need this permission
           Log.d("scancode", "denied permission before");
       }

       Log.d("perm", "fourth");
       //And finally ask for the permission
       ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_CONTACTS}, READ_CONTACTS_CODE /*can be any interge */);
   }
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
i just meant if u use CheckAndRequest, the request dislog will maybe skipped but you have a result no permission granted and you can show a description what to do.
means guide the user to the permission manager app or something how he can undo this "don't ask again".
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Have the logic to handle everything with nice messages


Not sure how to do the shouldShowRequestPermissionRationale command in B4A. Have you done this?


Used this code to bring them to the Application page: https://www.b4x.com/android/forum/threads/how-to-open-the-application-info-screen.32888/#content

Much as it doesn't bring them directly into the settings page it may work.

I would prefer to not have them fooling around there but just be able to request the permission again.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Have you done this?
myself not used this

just be able to request the permission again
what happens if you deinstall your app, will the permission request appear again if you set "don't ask again" and install it again?
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Tried using this code
B4X:
           Dim Intg As Int = 2
           Dim JO   As JavaObject
           
           JO.InitializeContext
           JO.RunMethod ("requestPermissions", Array As Object (Array As String (Permission), Intg))

To try and get around the CheckAndRequest.

BUT I guess after the user selects Don't ask again and selects Deny there is NO way of asking again.

So I guess I will have to give them a nice message and dump them into the settings screen and hope they figure it out.
 
Upvote 0

kisoft

Well-Known Member
Licensed User
HI
If the user does not approve runtime permissions, display the information panel that the application will not work and close the application.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
It is obvious actually. if the user said NEVER, you should not have an option for keep annoying the user.

If he change his mind, just show the instruccions to do it manually

  1. Open the App info (Settings - Apps - [app name])
  2. Select Permissions
  3. Enable the permission you denied with "never ask again"
 
Upvote 0
Top