Launch mode allows you to define how a new
instance or the existing instance of an activity is associated with the current
task. The activity launch mode has four valid values:
<activity android:launchMode = ["standard" | "singleTop" | "singleTask" | "singleInstance"] ../>
The default mode is "standard".
1. standard VS singleTop
The modes fall into two groups. standard and
singleTop comes in one side and singleTask and singleInstance comes in another
side.
The main difference between standard and singleTop is in standard, every time a new intent for standard activity, a new instance is created. In case of singleTop too, a new instance is created but an instance of the activity is already in top of the stack, it wont create a new instance.
The main difference between standard and singleTop is in standard, every time a new intent for standard activity, a new instance is created. In case of singleTop too, a new instance is created but an instance of the activity is already in top of the stack, it wont create a new instance.
Example:
Actually, the issue comes , when we download an application from a server and launch it and open it from there itself. After launching the application, press home button. Then click the all programs and select the icon of the application from home screen. Then another activity will be created in the case of standard, but in singleTop , no new instance will be created.
2. singleTask VS singleInstance.
The "singleTask" and
"singleInstance" modes also differ from each other in only one
respect: A "singleTask" activity allows other activities to be part
of its task. It's at the root of the activity stack, but other activities
(necessarily "standard" and "singleTop" activities) can be
launched into the same task. A "singleInstance" activity, on the
other hand, permits no other activities to be part of its task. It's the only
activity in the task. If it starts another activity, that activity is assigned
to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.
i will be
happy if you will provide your feedback or follow this blog. Any suggesion
and help will be appreciated.
Thank you :)