1. I added a new service, svcMyApp, revelant code:
Sub Service_Start (StartingIntent As Intent)
B4XPages.ShowPage("My App")
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
2. I added a new page, pgeMyApp, revelant code:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("myapp")
Dim sf As Object = xui.Msgbox2Async("Show My App?", "confirmation", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
'Log("Deleted!!!")
B4XPages.ShowPage("My App")
Else
'B4XPages.ShowPageAndRemovePreviousPages("MainPage")
B4XPages.ClosePage(Me)
End If
End Sub
3. add following code to the MainPage:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public pageMyApp As pgeMyApp
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
pageMyApp.Initialize
B4XPages.AddPage("My App", pageMyApp)
End Sub
Private Sub B4XPage_Appear
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
'xui.MsgboxAsync("Hello world!", "B4X")
StartService(svcStartMyApp)
End Sub
How to test it
1. Run the app (the attached project) and the main page will appear
2. Tap the Click button and the svcMyApp will cause the Dialog to apear.
3. Tap Yes, you'll see the MyApp page
4. Tap No, you'll be taken back the main page.
It works for me at least.