Reputation: 189
What are Some application examples, or use-cases where (singleInstance, singleTask, singleTop) serves a necessary purpose. i.e. why would one favor one launchMode over the other? so far my experience with them is strictly notes, so it would be helpful to understand where they're used. thank you!
Upvotes: 2
Views: 952
Reputation:
I understand it is known that it means you cannot launch multiple instances of an activity.
In my example, I use singleInstance
in my main launcher Activity
, because it has Fragments
, and it is being launched by notification intent.
If Activity
was sent to background after user touched "home" button, I don't want it to be launched from background via notification intent, because it will show the last seen fragment. If I set singleInstance
, it will always launch new instance of activity, and show the main fragment.
In my case I can't use singleTask
because it holds other activities from my app in the stack, but puts the main activity on top. I don't need that history in the stack.
singleTop
launches new instance on an activity only if it is not in top of the stack. if it is on top, it launches from background, that's what I don't need in my app.
Hope I was clear :)
Upvotes: 1