Android Question permission check and request and Wait For Activity_PermissionResul in B4XPAGES

vangogh

Active Member
Licensed User
Longtime User
hello
I am using the checkandrequest function to add a permission

I am using b4xpages (so this is not an activity)


checkandrequest:
' this is a B4Xpage

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")

    Dim PR As RuntimePermissions
 
    PR.CheckAndRequest(PR.PERMISSION_SEND_SMS)
 

    'here below the code stops executing - as this is not an activity (?)
    'Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
 
    ' if I use this (as I am using a b4xpage)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    '....NOPE, same issue: the code stops executing

    a=a+1 'this code in never executed

end sub

to bypass the issue, I removed the "wait for". The app works (without waiting for the user's choice)

removing the "wait for" it's OK for me, I am asking if something is still wrong and I should be careful

thank you
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
you are RUNNING CODE in sub Sub Class_Globals????? REALLY?
the rp-call should not be there.

sorry, no, I did a wrong copy paste in this post. of course it's not in class_globals .
it's in private Sub B4XPage_Created (Root1 As B4XView)
I fixed the code section in the post now

ok, sorry ,-) , let's go on

thank you

as I read in the post you linked:
"The CheckAndRequest method can only be called from an Activity."
weird, as point 1 says
1. Edit: In B4XPages the permission result event signature is: Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)

so I am using b4xpages, code is inside sub B4XPage_Created (Root1 As B4XView), i use Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
... same issue: the app stops there
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
See this example:

Make sure to have all the delegates in your app too

Main Module of a b4xpages-project. In this case from the Example at the project i linked

B4X:
#Region Delegates

Sub Activity_ActionBarHomeClick
    ActionBarHomeClicked = True
    B4XPages.Delegate.Activity_ActionBarHomeClick
    ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;
    
}
#End If
#End Region
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
@vangogh :

Please upload a sample application that reproduces your issue
 
Upvote 0
Top