I've read the thread "Android Process and activities life cycle" as well as the relevant portion of the book but they do not address the issue of object initialization and best practices for dealing with the Pause\Resume cycle.
Which things are guaranteed to persist in a Pause\Resume cycle?
Process Globals in other previously run Activity? i.e. top level "Activity Main".
Process Globals: Variables defined in Process Globals in this current Activity? i.e. Activity "Activity Sub"
Globals: Variables defined in globals and their values. Do they need to be re-initialized and values reassigned.
Loaded layouts - should they be reloaded on Resume?
In general:
- Process_Global variables persist as long as the process runs, no matter where they are defined.
- Layouts should be defined in Activity_Create, loaded from a file and / or defined in code.
With respect to numbers #4 and #5 it appears that they do NOT persist and have to be reloaded in Activity_Create\Resume otherwise the app Resumes to a blank screen.
You asked about the Pause\Resume cycle. 4. Loaded layouts - should they be reloaded on Resume?
The answer is NO. 5. Views added by variables located in Globals?
In the Pause\Resume cycle they are persistant.
If you change the screen orientation the cycle is Pause > Create > Resume then the layouts will be recreated in Activity_Create.
I think it is semantics as I'm sure you know the answers. But for the other newbies out there I wish to clarify the answers to the questions I posed.
1. Persist - variables and there values persist until the main thread is exited
2. Persist - variables and there values persist until the main thread is exited
3. No - these must be reloaded\recreated in Activity_Create or Activity_Resume
4. Yes - layouts must be reloaded in Activity_Create or Activity_Resume
5. No - These must be recreated in Activity_Create or Activity_Resume
3) 4) 5) layouts must be reloaded\recreated in Activity_Create not in Activity_Resume.
You may need to update contents of views in Activity_Resume but not reload\recreate the layouts.