Android Question Resume without Pause

TheWind777

Active Member
Licensed User
Longtime User
This has always confused me...

When the program starts-up, it runs the Activity_Create routine and then it runs the Activity_Resume sub when it hits the end of Activity_Create.

This is what it says in the manual.

If I make the smallest program one can make, a "Hello World" program.

B4X:
Sub Process_Globals
End Sub

Sub Globals
   DimEditTextHelloBoxAsEditText
End Sub

Sub Activity_Create(FirstTime AsBoolean)

   EditTextHelloBox.Initialize("EditTextHello")

   Activity.AddView(EditTextHelloBox,0,20%y,100%x,50dip)
   HelloWorld("Hello World")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed AsBoolean)
End Sub

Sub HelloWorld(Hello AsString)
   EditTextHelloBox.Text = Hello
End Sub

It calls Activity_Resume after calling Activity_Create.

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **

But... isn't it normal to do a

if FirstTime then
else
end if

in the Activity_Create routine... and wouldn't it be the same thing to put your code for Activity_Resume in the else part of the FirstTime if/then?

Is there some time that the system runs the Activity_Resume without first running Activity_Create?

Couldn't you just do all your Activity_Resume stuff after the FirstTime if/then, or is there some exception where it runs Activity_Resume without calling Activity_Create?


...

Or, is it because you MIGHT need to do MORE stuff than you did the very first time... so you put THAT stuff in the Activity_Resume area. I kind of get why you have two routines.
 
Last edited:

TheWind777

Active Member
Licensed User
Longtime User
If the activity is already created, you go to another activity, then return to the first activity, the sub Activity_Resume will run without first running Activity_Create.

Huh. That's why I never ran into it. Have always used only one Activity.
 
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
If the activity is already created, you go to another activity, then return to the first activity, the sub Activity_Resume will run without first running Activity_Create.

What's the advantage of using more than one Activity? Does it not load into memory unless they ask for it, thus saving resources unnecessarily?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User

How can one maintain a menu if you have multiple Activities?

Isn't a menu particular to one Activity?

Can you select from a menu and go to a different activity?
 
Upvote 0

Similar Threads

Replies
2
Views
654
Replies
15
Views
43K
D
  • Question
Android Question Activity_Resume run 2 times
2 3 4
Replies
65
Views
10K
Deleted member 103
D
Cookies are required to use this site. You must accept them to continue using the site. Learn more…