Private Sub CheckPermissions As ResumableSub
Dim fLocation As Boolean = Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
Log(fLocation)
If fLocation = False Then
PermissionsPage.Initialize("PermissionsPage")
Root.AddView(PermissionsPage,0,0,100%x,100%y)
PermissionsPage.LoadLayout("Permissions")
UTIL.SetAllTags(PermissionsPage)
Dim Args() As Object = Array("CheckPermissions", -1 , -3)
Wait For (WaitKbd(Args, Null)) complete (rValue As WaitKbdType)
If rValue.Tag <> -3 Then
ExitApplication
End If
Log("Check PERMISSION_ACCESS_FINE_LOCATION")
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For B4XPage_PermissionResult(Permission As String, Result As Boolean)
Log("After Permission Wait")
If Not(Result) Then
Dim answ As Object
answ = xui.MsgboxAsync("App cannot be used without permission. Please restart and grant access.","Permissions Defect")
Wait For (answ) Msgbox_Result (exitResult As Int)
ExitApplication
End If
Else ' permission already granted
Starter.StartGPS
End If
Return True
End Sub