Android Question Should/Could I use Activity_PermissionResult in B4XPage instead of B4XPage_PermissionResult

Daica

Active Member
Licensed User
I am using B4XPages for my application and when I need to request permission for something, I would go with the default way of using
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)

I use this on an emulator, however, sometimes this doesn't work on a real device so instead, I use
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

Using Activity_PermissionResult works fine as well. I was wondering if it's okay to be using Activity_PermissionResult instead of B4XPage_PermissionResult since the Activity_PermissionResult works.
 

LucaMs

Expert
Licensed User
Longtime User
It is rarely necessary to write code in the Activity Main, when using the B4XPages.

If
B4X:
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
doesn't work for you, that means something is wrong.

Post your code.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
doesn't work for you, that means something is wrong.
using Activity_PermissionResult it does work; he wrote that using B4XPage_PermissionResult it does not work all the time.

But i agree; he need to post his code.
 
Upvote 0

Daica

Active Member
Licensed User
This is how I request permission in all my project using B4XPage


B4X:
Sub Class_Globals
Private rp As RuntimePermissions
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
gmap = MapFragment1.GetMap
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
    'Do Stuff Here
Else
    Log("No permission!")
End If
End Sub

Am I supposed to replace B4XPage with the actual page name or leave it as default? I leave it as it is
 
Last edited:
Upvote 0

Daica

Active Member
Licensed User
Your code is correct.

I would hope so since I copied from examples found on this forum :)
The only thing is, sometimes the map or whatever permission I requested would never return to the B4XPage_PermissionResult event.
It'll ask for permission on first run ( from new install) and then it would work for the first time. When I exit the app and go back, nothing happens

When I change it to Activity_PermissionResult, it would then work fine.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
would hope so since I copied from examples found on this forum :)
The only thing is, sometimes the map or whatever permission I requested would never return to the B4XPage_PermissionResult event.
It'll ask for permission on first run ( from new install) and then it would work for the first time. When I exit the app and go back, nothing happens

When I change it to Activity_PermissionResult, it would then work fine.
Try to reproduce it in a small project and upload it.
 
Upvote 0
Top