Android Question CheckAndRequest permissions always false

nibbo

Active Member
Licensed User
Longtime User
Hi All

RuntimePermissions.CheckAndRequest is not displaying a dialog and always returns false!

B4X:
    If phone.SdkVersion >= 24 Then
        Dim rp As RuntimePermissions
        rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) 
        Wait For Activity_PermissionResult (Permission As String, rpResult As Boolean)
        If Not(rpResult) Then
            'no permission
            Msgbox("Unable to access device storage.", "Warning")
            Return False
        End If
    End If

Testing on a device with SDK version 25.
I thought that this should display a dialogue the first time it is called for an app and then retain the users choice for subsequent runs but I never saw a dialogue.
Pretty sure it used to work?

Thanks
 

Sandman

Expert
Licensed User
Longtime User
I don't think that udg meant for you to place that code in a separate module, rather just replace every instance of your old msgbox in place. As far as I can tell, it should work. That's what I did with my app recently, and it seems to work nicely. (I didn't have as many as you do so I hunted them down by hand, didn't have to script it.)
 
Upvote 0

nibbo

Active Member
Licensed User
Longtime User
I don't think that udg meant for you to place that code in a separate module

But.... with nested subs the wait will not cause the whole app to wait, just the sub the wait is in.

If SubOne calls SubTwo which calls SubThree and SubThree has a Wait after MsgBoxAsync then SubThree will stop but SubTwo (and SubOne after) will carry on processing.
For the suggestion to work I would need to get SubOne to wait for SubTwo which would have to wait for SubThree which would wait for the MsgBoxAsync.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Waits in nested subs will pass control back to the the calling subs unless they are all resumable with waits.
Sorry, I missed this point from you earlier posts.
Anyway, the same "parsing" tool could operate the switch from regular Sub declaration to a ResumableSub declaration in case of "cascading" subs.
I mean:
Sub SubThree becomes Sub SubThree as ResumableSub and as a last statement you add Return Null
Then Sub SubTwo follows the same route but when it calls SubThree you modify it to become a WaitFor (SubThree)...
This should account for most of the subs.
A bit more complex would be for subs returning a value (e.g. Sub SubX as int); to comply even with those the "parser" should be able to read all the declarations beforehand, then operate the proper substitutions (Returns and Response types).
Complex but doable, I think.

ps: read it just as a rough aloud reasoning..
 
Upvote 0
Top