Yevgeny Simkin
Yevgeny Simkin

Reputation: 28379

I would love some clarification on the different Activity launch modes

I'm trying to make sense of, but failing to, the documentation's distinction between singleTask and singleInstance. They both look like singletons to me. Could someone please elaborate on how they're different and maybe note an example of where one might choose to use one over the other? I don't need an explanation of the singleTop and the default launchMode, I'm only confused about these two.

Upvotes: 0

Views: 76

Answers (2)

David Wasser
David Wasser

Reputation: 95618

Have a look here for an explanation of what a "task" is in Android. Perhaps that will help you understand.

Upvotes: 1

Yusuf X
Yusuf X

Reputation: 14633

From the documentation: 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 always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that 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.

Does that answer your question, or do you need more clarification?

Upvotes: 1

Related Questions