I must be missing something fundamental here. I have read through forum and watched tutorials.
In a B4XPage app, everything is fine when doing CheckandRequest permission the first time. B4XPage_PermissionResult is raised. However, after that, the event is not raised. Execution stops on the WaitFor. Other events (like Click) are still fired.
Relevant stuff:
Manifest
Main
B4XMainPage
Log 1st Time:
** Activity (main) Create, isFirst = true **
*** mainpage: B4XPage_Created
1
2
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
*** mainpage: B4XPage_PermissionResult [mainpage]
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]
3
past Location
Log After Permission Granted:
** Activity (main) Create, isFirst = true **
*** mainpage: B4XPage_Created
1
2
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
In a B4XPage app, everything is fine when doing CheckandRequest permission the first time. B4XPage_PermissionResult is raised. However, after that, the event is not raised. Execution stops on the WaitFor. Other events (like Click) are still fired.
Relevant stuff:
Manifest
B4X:
AddPermission("android.permission.ACCESS_FINE_LOCATION")
Main
B4X:
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub
B4XMainPage
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private rp As RuntimePermissions
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
CheckPermissions
End Sub
Private Sub CheckPermissions
Log("1")
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Log("2")
Wait For B4XPage_PermissionResult(Permission As String, Result As Boolean)
Log("3")
If Not(Result) Then
Log("location deny")
Else
Log("past Location")
End If
End Sub
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
End Sub
Log 1st Time:
** Activity (main) Create, isFirst = true **
*** mainpage: B4XPage_Created
1
2
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
** Activity (main) Pause event (activity is not paused). **
*** mainpage: B4XPage_Disappear [mainpage]
*** mainpage: B4XPage_PermissionResult [mainpage]
** Activity (main) Resume **
*** mainpage: B4XPage_Appear [mainpage]
3
past Location
Log After Permission Granted:
** Activity (main) Create, isFirst = true **
*** mainpage: B4XPage_Created
1
2
*** mainpage: B4XPage_Appear
** Activity (main) Resume **