Except being the first Activity upon the Start of the Application, is there anything else special about main activity? From:https://developer.android.com/codelabs/android-training-create-an-activity#0
An app usually consists of multiple screens that are loosely bound to each other. Each screen is an activity. Typically, one activity in an app is specified as the "main" activity (MainActivity.java), which is presented to the user when the app is launched. The main activity can then start other activities to perform different actions.
From the quote above it seems to me that we have following hierarchy:
but then further is said:
Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a new activity starts, that new activity is pushed onto the back stack and takes user focus. The back stack follows basic "last in, first out" stack logic. When the user is done with the current activity and presses the Back button, that activity is popped from the stack and destroyed, and the previous activity resumes.
Does this also apply to the "MainActivity"
? If the "MainActivity"
is destroyed does that cause the App to crash i.e does the lifecycle of the MainActivity
in any way differs from the lifecycle of any other activity? Is the MainActivity the last activity that is being stopped when the App is exited?
Why do I need this:
I would like to free some resources when the App is exited (in the onStop()
Method (because post Honeycomb it is guaranteed that onStop
will be called)), especially ExecutorServices
, I've read here that even though App is exited there is no guarantee that an ExecutorService
will be stopped and will make JVM continue working/running, even though App is closed/killed and will continue to use system resources.