Android Question runtimepermissions strange behaviour

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
B4X:
        Dim rp As RuntimePermissions
        For Each permission As String In Array(rp.PERMISSION_GET_ACCOUNTS,rp.PERMISSION_READ_CONTACTS)
            rp.CheckAndRequest(permission)
            Wait For B4XPage_PermissionResult (permission As String, Result As Boolean)
            If Result = False Then
                Log(permission & " denied")
                Return
            End If
        Next
In B4XPages, above code works fine if we don't grant it, Log(permission & " denied") fired.
If we grant it and call it again, code crash & through error:
B4X:
Sub activity_permissionresult was not found.

Any explanation?
 

drgottjr

Expert
Licensed User
Longtime User
nothing strange going on; activity_permissionresult is hardcoded in the runtimepermissions.class. that's what it wants, that's what it's looking for, not B4XPage_PermissionResult
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
talkin' to me? or him? i'm running runtimepermissions 1.12 on b4a 11.50 from 21.03.2022. internal only. should i be using something else?
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
Nothing modified, runtimepermissions lib 1.12
Can you check the attached example, please.
After you run it: grant the permission, After that click again on button, app will crash!
 

Attachments

  • rptest.zip
    10.1 KB · Views: 189
Upvote 0

agraham

Expert
Licensed User
Longtime User
Your example works fine for me with repeated button presses and no error on all the devices I have readily to hand
Samsung Tab A 8 2019 with Android 11
Redmi Note 9 Pro and Android 11.
Microsoft Surface Duo and Android 11.
Google Pixel 4a and Android 12.
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
My doubt increased! this work fine, why OP not work!
B4X:
    Dim rp As RuntimePermissions
    For Each permission As String In Array(rp.PERMISSION_GET_ACCOUNTS,rp.PERMISSION_READ_CONTACTS)
        If rp.Check(permission)=False Then
            rp.CheckAndRequest(permission)
            Wait For B4XPage_PermissionResult (permission As String, Result As Boolean)
            If Result = False Then
                Log(permission & " denied")
                Return
            End If
        End If       
    Next
    Log("You are here")
Is CheckAndRequest has internal problem?
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
Runtimepermissions strange behaviour, I was about to ask about this very same problem.

No. I'm just checking your example as you asked. What conclusions you draw are up to you.
It is not the code, I tested your "B4XPages enhanced example" and it had the exact same behavior that OP describes.

You are using an old version of RuntimePermissions. Delete it from the internal libraries folder and reinstall B4A.

Looks like there is a problem with the way internal libs are updated. The version in the IDE was 1.12 but still the old behavior. I deleted the Install folder, reinstall B4A and it is working with pages now.

Maybe the file RuntimePermissions.androidx.jar was the problem

Any explanation?

Did you try the proposed solution by Erel? Do you have a RuntimePermissions.androidx.jar file in your internal libs?

the OP uses an old RuntimePermissions library.

Could the installer be improved to delete this obsolete files?
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
1. Delete all the internal libraries.
I have a lot of additional files inside it, if I deleted it, I'll missed these files (but I can overcome this problem).
Could the installer be improved to delete this obsolete files?
Yes, It is better to improve installer for next releases to be smooth and silent.
 
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
This is a big mistake. You shouldn't copy libraries to the internal folder. This is exactly the purpose of the additional libraries folder.
Yes, it should not be touched manually, But older B4A versions was not has additional libs folder, I was add any new libs to it. I'll solve this. thanks
 
Upvote 0
Top