Activities - more info required

CanelaKid

Member
Licensed User
Longtime User
Point 1 - When starting a second activity within Main.Activity_Create, Main.Activity_Resume seems to be called before Main.Activity_Pause.
Is this correct?

Point 2 - In the code below Activity_Resume is first called when 'ExitApp' = -1, as you can see from the logs other code from this Activity (incl. DBopen which adds more logs - 'Must Have') seems to be executed BEFORE the second Activity 'zAppReg' is created. Note, however, if I uncomment the msgbox all seems to follow the order I would expect.

Sub Activity_Resume
Try
If ExitApp = -1 Then StartActivity("zAppReg")
If ExitApp = 0 Then ExitApplication
Log("How Come?")
'Msgbox("After Reg","")
zDBmanager.DBopen ' Open DB if not already open
Activity.LoadLayout(App(0))
If File.Exists(zDBmanager.DBlocation,zDBmanager.DBname) Then
Msgbox("Created","")
Else
Msgbox("Not Created","")
End If
Catch
Alert("Resume Problem",0)
End Try
Return
End Sub

Associated runtime logs -
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
How Come?
Must Have
Must Have2
Must Have3
Must Have4
Must Have5
Must Have6
Must Have7
Must Have8
Must Have9
** Activity (main) Pause, UserClosed = false **
** Activity (zappreg) Create, isFirst = true **
** Activity (zappreg) Resume **

Maybe I still don't understand the ins and outs of the activities. Thoughts anyone?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Point 1 - When starting a second activity within Main.Activity_Create, Main.Activity_Resume seems to be called before Main.Activity_Pause.
Is this correct?
No, it is not correct. The current activity is first paused and then the second activity is resumed (and first created if needed).

When you call StartActivity a message is sent to the message queue with this instruction. The message is only processed when your current code finishes executing. It doesn't happen immediately.
 
Upvote 0

CanelaKid

Member
Licensed User
Longtime User
Thanks Erel

Your explanation of Point 2 probably also accounts for my assumptions in point 1
Now I am aware of that I can work with it no problem. Thanks again
 
Upvote 0
Top