Thanks Guardian17. I've revised the use cases below and added some new ones.
You say
I have further learned that you can use Activity.Finish to exit the second Activity, which will allow you to fully exit the Activity in which it is used.
In fact, Android remembers that you have already entered the second activity, so the next time you enter it, FirstTime will be False.
the Activity in which you may use StartActivity(Main) may remain in memory in a Paused State
I'm not sure why you would want to do this, since the history traced by the Back button would then be First Activity, Second Activity, First Activity. Wouldn't this be a little confusing for the user?
Here's the revised list of use cases.
When the user first launches your app or brings it to the front after quitting
(Quitting could be by pressing the Back button or your app calling Activity.Finish.)
- If the user has not previously run your app, or if she has and the Process has been killed:
A new Process is created.
Process_Globals is run in all activities.
Globals is run.
Activity_Create is run with FirstTime parameter set to True.
Activity_Resume is run.
- If the user has previously run your app and the Process has not yet been killed:
Process_Globals is run in all activities.
Globals is run.
Activity_Create is run with FirstTime parameter set to True.
Activity_Resume is run.
When the user runs another app
Activity_Pause is run with the UserClosed parameter set to False.
(Android will determine when the Process ends.)
When the screen is turned off
Activity_Pause is run with the UserClosed parameter set to False.
When the screen is turned back on
Activity_Resume is run.
When the user clicks the Back button
Activity_Pause is run with the UserClosed parameter set to True.
(Android will determine when the Process ends.
The next time the app is run, Process_Globals will be run.)
When the user brings your app to front after running a different app
- If Android has not killed your app’s Process:
Globals is run.
Activity_Resume is run.
- If Android has killed your app’s Process:
Process_Globals is run.
Globals is run.
Activity_Create is run with FirstTime parameter set to True.
Activity_Resume is run.
When the user rotates the device
Activity_Pause is run with the UserClosed parameter set to False.
The screen takes on its new configuration.
Globals is run.
Activity_Create is run with FirstTime parameter set to False.
Activity_Resume is run.
When your app calls Activity.Finish
(You might have an Exit button which calls this.)
Activity_Pause is run with the UserClosed parameter set to True.
Android will determine when the Process ends.
When one activity opens another using StartActivity
First activity calls StartActivity(SecondActivity)
Sub in first activity finishes running.
First Activity calls Activity_Pause with the UserClosed parameter set to False.
Second activity runs Process_Globals.
Second activity runs Globals.
Second activity runsActivity_Create.
(FirstTime parameter is either True or False depending whether second activity has run before.)
Second activity runsActivity_Resume.
When second activity closes and first activity resumes
(For example if second activity calls Activity.Finish)
Second activity calls Pause with UserClosed set to True.
First activity runs Resume.