Activity Launch Modes

Posted By : Chandan Wadhwa | 06-Jun-2016

A task is a collection of activits to which user interact while plaing with activities.

When user launch a new activity it is added into the task list of activity. So a task list can contains more the one activities instance of same activity. This can be handle using the activity launch mode.

There are four launch modes of activity :-

  1. Standard
  2. Single Top
  3. Single Task
  4. Single Instance

 

Standard Launch Mode :- This is also the default launch mode of android for launching activity. The system create a new instance of activity in task list of activity it doesn't care about whether activity instance is already created in task list. So task list can contains multiple instance of same activity. 

Sigle Top Launch Mode :- If the instance of the activity already exists on the top of task list of activity statck then system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity. But  if the activity at the top of the back stack is not an existing instance of the activity the activity can be instantiated multiple times.

Example :-  Activity task list contains (A -> B -> C )  if we again launch the C Activity then android systme doesn't create the new instace of C . On another scenario if activity task list contains (A -> C -> B )  if we again launch the C then task list will be like (A -> C -> B -> C )

Single Task Launch Mode :- The system creates a new instantiates of the activity at the root of the new task. However, if an instance of the activity already exists in a task list, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.

Example :- Activity task list contains (A -> B -> C )  if we again launch the B Activity then android systme doesn't create the new instace of B and activity task list will be (A -> C -> B).

Single Instance Launch Mode :- Single Instance mode is same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task.

 

To start an activity with any specific launch mode we add the launch mode property inside activity tag in manifest file. 

 
 

THANKS

About Author

Author Image
Chandan Wadhwa

Chandan is an Android Apps developer with good experience in building native Android applications.

Request for Proposal

Name is required

Comment is required

Sending message..