Bogdan_Popa

Member
Licensed User
I've discovered the bug in B4A V9.50, after changeing the package name of my app.
The issue is that the request window dose not apear, unlike on the previous versions of my app, compiled with older versions of B4A(eg V9.30).

Permision request from "Main":
B4X:
Sub Activity_Create(FirstTime As Boolean)   
    Activity.LoadLayout("Main")

    Try
        If FirstTime Then
            
            ' Permisions
            Dim RTP As RuntimePermissions
            RTP.CheckAndRequest(RTP.PERMISSION_WRITE_EXTERNAL_STORAGE)

            ' Login
            Activity.Finish
            StartActivity("frmLogin")
        End If
    Catch
        
    End Try
End Sub
After a day of fiddling with the code, i've manage to find a solution: move "RTP.CheckAndRequest(RTP.PERMISSION_WRITE_EXTERNAL_STORAGE)" to "frmLogin" activity module from "Main" activity module.

This little bug caused me a lot of problems because it was hard to spot and i had the permisions granted from B4A V9.30.

Thanks,
Bogdan
 

Erel

Administrator
Staff member
Licensed User
This code is wrong and its behavior is not related to B4A version.

There are several mistakes here:
1. Requesting the permission, once, when the app starts is a mistake. You should always request the permission, right before you need it.
2. Starting an activity right after requesting the permission will not work. You should wait for the PermissionResult event and only then start the next activity:
B4X:
rtp.CheckAndRequest(rtp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
StartActivity(frmLogin)
 

Bogdan_Popa

Member
Licensed User
Hi Erel,

Thanks for the fast response!
:oops:
I've deleted by mistake the "Wait For Activity_PermissionResult (Permission As String, Result As Boolean)" with some other coments and code. ( :D it's my first post, sorry).
I've recheckd my code and the window apears, but it's in the background.

Please see the short recording I made. In the short time the window is displayed, the app in a breakpoint.

After I stopped the recording and the app I found the window opend.
https://imgur.com/a/0wjQ4uW
 
Last edited:

Erel

Administrator
Staff member
Licensed User
There is no bug here. Your code is wrong.
There are many mistakes here and I recommend you to watch the runtime permissions and resumable subs video tutorials.

Specifically you are starting the next activity in Activity_Resume. When you call Wait For in Activity_Create, the code flow will continue with Activity_Resume. Your Activity_Resume code starts the next activity.

For further discussion please start a new thread in the questions forum.
 

Bogdan_Popa

Member
Licensed User
Thanks for the response.
I understood my mistakes and removed from Activity_Resume the check user sequence, also i've rewach the videos.
 
Top