Essential Android Activity edit forum

Activity launchMode

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 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.


Table Of Contents
39 ACRA
48 Activity
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
  ↑ ↓ to navigate     ↵ to select     Esc to close