Android Question [SOLVED] - Trapping the result of a permission request


Well-Known Member
Licensed User
Longtime User

I created a permission test app to see how it works and this simple app does ask the user for the READ_PHONE_STATE permission so I know the manifest editor is set up correctly but the flow of coding ignores the statements following the CheckAndRequest statement.

Coding from the simple permission test app.:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
End Sub

Public Sub Initialize
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)

    Log("At B4XPage_Created")
    Root = Root1
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub Button1_Click
    xui.MsgboxAsync("Hello world!", "B4X")
End Sub

Sub CheckPermissions
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

    If Result Then
        Log("We have permission")
        Log("We don't have permission")
    End If
End Sub

Here are the logs from the app. I have several Log statements so I can see wether or not the user accepts the permission request. The only Log statement here is At B4XPage_Created. Nothing is shown to indicate wether the user has accepted or denied the permission request.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
At B4XPage_Created
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **

As you can see from the logs the other Log statements are never executed. Please let me know what I have missing.



Well-Known Member
Licensed User
Longtime User
The first thing I noticed: wait for B4XPage_PermissionResult instead of Wait For Activity_PermissionResult
You nailed it! šŸ‘ Thanks so much. How did you learn about the differences in B4XPages?

Are you aware of a thread for those of us that who are migrating over to B4XPages that explains all of the differences so our transitions will be easier?
Upvote 0