Android “launchMode” (Visualized)
Android launchMode is important thing and all android developers should know how launchMode works. Most of developers (including me) think that we know why it is used. But we are wrong. It is not just about making activity singleTask to prevent duplicate instance. OK you are right. It solves our problem but do we really know what happens to other activities in the stack when we make activity singleTask?
There is a really really good blogpost about how launchMode works. Thanks to Amit for blogpost. But I want to visualise it to be understandable at first glance. I will show just launchMode that we use in AndroidManifest. Next blogpost I will visualise intent flags.
First of all I want to give you two image to make it more understandable.
1 — launchMode = “singleTop” in Activity D
2 — launchMode = “singleTask” in Activity C
3 — launchMode = “singleInstance” in Activity E
Yes. Activity E is created in new task. What if we want to launch Activity F from Activity D? Here is the result;
4 — launchMode = “standard” in Activity B
Happy coding.
Recommend it If you like it :) Thanks to Amit Shekhar.