The Android system keeps linear navigations of the history of the activities traversed called backstack. Using the BACK key, user can get to the previous activities in the order they get into the stack. The BACK key limits to show the activities further than the last visit to the HOME. Adding an activity to the current stack is regardless of whether the activity is in the same task or begins a new one. A task consists of one or more than one activities that the user uses to accomplish an objective (like any given transaction). Hence the backstack can be of more than one activity in one task or more than one task. In the later case, going back can let the user go back to activities in previous task. To switch between tasks user can selects its root activity from the application launcher. Activity that starts a task is a root activity. Until a new task is explicitly specified, all activities the user starts are considered to be in the same task. Hence the BACK key helps to get to the previous activities in this task. It is possible to have two tasks running simultaneously and user can jump between these tasks to perform actions. This can be done by pressing the HOME key. E.g. if from Home page Application A is started which starts Activity 1. It’s a new task. Activity 1 starts Activity 2. While the user is in Activity 2, some action needs to be performed in Application B which has Activity 3. Activity 3 has to be started from HOME. So the user press HOME and starts Application B (new application, new task) and perform some actions. Remember the Activity 2 in previous task is stopped not destroyed and hence it can be regained in the state it was left once the user again go to HOME and get back to the previous task. Hence the flow can be: HOME->Application A(Task 1)->Activity 1->Activity 2 ->HOME -> Application B (Task 2)->Activity 3 ->HOME->Application A(Task1)->Activity 2(restore the state as left)
Starting a new task:
* Act to a notification
* Press HOME and start a new application
* Start an activity that defines a new task (done explicitly)
A single task can comprise of more than one application. Starting a new application from the current activity is in the same task. To conclude, when a user act to a notification or start a new task explicitly, the backstack consists of more than one task. A new task started by beginning a new application from the HOME, the traversing of activities through BACK leads to same task.
Contributed by Purvi Patel, SDE Android – TringApps Inc