Reputation: 2592
There are four launch modes for an Activity, standard, singletop, singletask, and singleInstance. The previous three are relatively easy understanding and widely used. But till now, I did not find any scenario using singleInstance.
Have any one used it before?
Upvotes: 4
Views: 4362
Reputation: 627
singleInstance launchmode will be used when you do not want any other activity to be a part of the task.Its the only activity in the task. As this launchmode does not permit that.
Upvotes: -2
Reputation: 95618
There is never a reason to use singleInstance
launch mode.
If you are building a "home screen" replacement or a launcher type application, you would use singleInstance
or singleTask
launch mode to ensure that your Activity
is always the root of its task. This makes sure that if another application launches your Activity
, that Activity
does not get launched into the task of the calling application and it also ensures that there is only ever one instance of your Activity
created.
If you are writing a "home screen" replacement application, you can always make sure that no other activities get launched into your own task by always specifiying Intent.FLAG_ACTIVITY_NEW_TASK
when launching other activities. In that case, you can use launch mode singleTask
. So there is no reason to use launch mode singleInstance
. But it probably wasn't clear to the original developers of Android at the time.
Upvotes: 4
Reputation: 896
SingleInstance launch mode should only be used in the applications that are implemented entirely as one activity. Only one instance 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 seperate task.
Upvotes: 1