We often confused with Android Activity Launch Mode when we see
android:launchMode
attribute associated with <activity> element in manifest file, it defines the way of associated task. A task is a collection of activities that users interact with when performing any job. Task uses STACK to maintain the history of activites.
Android Activity has four Launch Mode as described below.
“standard” (Default Launch Mode)
<activity android:launchMode="standard" />
A new instance of activity is created every time in the task from which it was started. Multiple instances of activity can be create and each instance may belongs to different task.
“singleTop”
<activity android:launchMode="singleTop" />
If instance of activity is present on top of Task stack, a new instance will not be created and system will route activity intent information through onNewIntent(). If it is not present on top, a new instance of activity is created. Multiple instance of same activity can be created and each instance may belong to different task and pushed at the top of the stack.
“singleTask”
<activity android:launchMode="singleTask" />
A new task will be created and a new instance of the activity will be pushed at root of new task. If activity instance exists on the separate task then system routes the call to existing instance through onNewIntent() method. Only one instance will exist at a time. So clear the other existing instance at the top of singleTask instance and pushed its instance at top into the stack.
“singleInstance”
<activity android:launchMode="singleInstance" />
Only one instance of activity will exist at a time. System will not launch any other activity into task holding this type. It is always a single member of its task and activities started from here will open into separate task. means only one instance of activity will be in single task at a time.
Even multiple time using singleInstance instance of the activity. Always single instance is available for the same into separate stack.
Even multiple time using singleInstance instance of the activity. Always single instance is available for the same into separate stack.
No comments:
Post a Comment