Sub Class_Globals
Private Root As B4XView
Private xui As XUI
....
Private bPageCreated As Boolean
End Sub
'
Private Sub B4XPage_Created (Root1 As B4XView)
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Dim sCodeName As String = "B4XMainPage_Created"
LogColor($"Sub: ${sCodeName}"$, ModColour)
Root = Root1
Root.LoadLayout("tmm_main_std")
Try
Dim cs As CSBuilder
B4XPages.SetTitle(Me, cs.Initialize.Color(xui.Color_RGB(210,105,30)).Append("The Music Machine").PopAll)
' Initialize the TMM_Run activity class with TMM_RunPage
TMM_Run.Initialize
TMM_DBUpdates.Initialize
' Add the page before we call any wait for subs
B4XPages.AddPage("B4XPTMM_RunID", TMM_Run)
.... etc
For Each permission As String In Array(rp.PERMISSION_READ_PHONE_STATE,rp.PERMISSION_WRITE_EXTERNAL_STORAGE,rp.PERMISSION_RECORD_AUDIO)
rp.CheckAndRequest(permission)
Log("requesting: " & permission)
Wait For B4XPage_PermissionResult (permission As String, Result As Boolean)
If Not(Result) Then
Msgbox2Async ("You must restart The Music Machine and agree to all the permissions for The Music Machine to continue.", _
"The Music Machine", _
"", "OK", "",cmTMM.gbmpLogo36x36,False)
Wait for MsgBox_Result
cmTMM.gbAppClosing = True
B4XPages.ClosePage(Me)
End If
.... etc
bPageCreated = True
Catch
Dim sErrorMsg As String = "TBCI App Error: " & CRLF & LastException
LogColor ($"${sCodeName}:${sErrorMsg}"$, Colors.Red)
MsgboxAsync (sErrorMsg, sCodeName)
End Try
End Sub
'
Private Sub B4XPage_Appear
Dim sCodeName As String = "B4XMainPage_Appear"
LogColor($"Sub: ${sCodeName}"$, ModColour)
LogColor($"Logs in Main are in this colour"$, ModColour)
Start = DateTime.Now
' Not in the list? AddPermission(android.permission.WAKE_LOCK)
' Start the main setup routines
Run_MainSetup1
' Ask if user wants to load updates
Run_MainSetup2
' After PageCreated is complete, allow the flash screen to show for FLASHONSCREEN_MSECS then go to the Run page
Do While Not(bPageCreated)
Sleep(500)
Loop
LogColor($"B4XMainPage_PageCreated is finished: ${bPageCreated}"$, ModColour)
B4XPages.ShowPage("B4XPTMM_RunID")
End Sub