Activity launchMode

suggest change

Launch mode defines the behaviour of new or existing activity in the task. There are possible launch modes:

It should be defined in android manifest in <activity/> element as android:launchMode attribute.

<activity
    android:launchMode=["standard" | "singleTop" | "singleTask" | "singleInstance"] />

Standard:

Default value. If this mode set, new activity will always be created for each new intent. So it’s possible to get many activities of same type. New activity will be placed on the top of the task. There is some difference for different android version: if activity is starting from another application, on androids <= 4.4 it will be placed on same task as starter application, but on >= 5.0 new task will be created.

SingleTop:

This mode is almost the same as standard. Many instances of singleTop activity could be created. The difference is, if an instance of activity already exists on the top of the current stack, onNewIntent() will be called instead of creating new instance.

SingleTask:

Activity with this launch mode can have only one instance in the system. New task for activity will be created, if it doesn’t exist. Otherwise, task with activity will be moved to front and onNewIntent will be called.

SingleInstance:

This mode is similar to singleTask. The difference is task that holds an activity with singleInstance could have only this activity and nothing more. When singleInstance activity create another activity, new task will be created to place that activity.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents