I read the official documentation and understood that singleInstance is always opened by creating a new task. So I thought that if I run two activities with the same taskAffinity, only the last opened activity will be on the back stack. However, when two activities are opened as singleInstance with the same taskAffinity, both activities are stacked on the back stack. How do I understand singleInstance?
SingleInstance of Android launchMode
575 views Asked by Ji Sungbin At
1
This one is pretty easy:
taskAffinitytrumpslaunchMode. This means, if you launch anActivityand thatActivityhas the sametaskAffinityas other activities within a task, the speciallaunchModessingleTaskandsingleInstanceare ignored.So unfortunately, the documentation isn't 100% correct, because there are some situations where
singleInstanceandsingleTasklaunch modes do NOT behave the way they are documented.In general, you should not be using the special launch modes
singleTaskorsingleInstanceas these come with a lot of side-effects that are not obvious. You shouldn't need these special launch modes unless you are implementing a HOME-screen replacement.