In short: do initialization in YourApplication.onCreate , not some LaunchActivity
Documents for verification:
- Processes and threads
- API Guides> Actions
Can I rely on startup activity to initialize the Application class?
Yes, if you remember that an application can last longer than activity and activity can be killed and recreated. I am not sure that the intention will be resurrected. Activity get: LAUNCH or VIEW (For the scenario when the activity was killed as too heavy, while the long-term maintenance was tied to the application)
Are there any cases where an application class can be recreated without creating launch activity?
yes, if the last visible activity was not LaunchActivity
check the life cycle of an android application and using static
Is it possible that the process was killed when the phone slept, and when the phone woke up, the application class was recreated, the top activity in the stack resumed, but the start of activity.onCreate was not started in this way the Application class was not initialized?
If there were several different running processes, A, B, C and their entire process was killed, I think that Android OS is only good at creating applications and C-activity, while A and B will be redrawn upon access, that is, upon returning to him.
Is it possible to assume that an instance of the application class will exist as long as the process
Yes
and that when creating an application class, it is equivalent to "restarting" the application, i.e. start with a new activity stack (and the first activity on the stack is the launch)?
I'm not sure when the restart will start first, and, but the last one, that is, the one that the user should see.