Changes

Understanding Android Application and Activity Lifecycles

No change in size, 18:08, 26 June 2013
no edit summary
== Android Process States ==
Processes host applications and applications are made up of components. Within an Android system, the current state of a process is defined by the highest ranking active component within application that it hosts. As outlined in Figure 98-1, a process can be in one of the following five states at any given time:
[[Image:android_process_priorities.png|Android Process Priority Diagram]]
Figure 98-1
== The Activity Stack ==
For each application that is running on an Android device, the runtime system maintains an Activity Stack. When an application is launched, the first of the application’s activities to be started is placed onto the stack. When a second activity is started, it is placed on the top of the stack and the previous activity is pushed down. The activity at the top of the stack is referred to as the active (or running) activity. When the active activity exits, it is popped off the stack by the runtime and the activity located immediately beneath it in the stack becomes the current active activity. The activity at the top of the stack might, for example, simply exit because the task for which it is responsible has been completed. Alternatively, the user may have selected a “Back” button on the screen to return to the previous activity, causing the current activity to be popped off the stack by the runtime system and therefore destroyed. A visual representation of the Android Activity Stack is illustrated in Figure 98-2:
[[Image:android_activity_lifecycle_diagram.png|Android Activity Stack Diagram]]
Figure 98-2