Good morning, I am investigating the launch modes of activities in android.
I am developing an application where there should only be one instance of an activity (A), if it were the case that there were more instances of the activity it could cause errors in the execution of the application, investigating a little I reached the point of finding these two activity start modes
android:launchMode="singleTask" y android:launchMode="singleInstance"
In the play store I found this app that shows how the types of activity launches work in android https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode The problem is that when I start these activities in both modes seem to do the same thing and I would not want to make a mistake in which to choose to start my activity, I hope you can help me identify the difference between both launch modes, since I did not understand the information in the official documentation very well, beforehand Thanks a lot
Official documentation: https://developer.android.com/guide/topics/manifest/activity-element.html?hl=es-419
To understand the difference, you can review in the documentation what the “singleTask” and “singleInstance” modes are intended for:
Activity android:launchMode
For an activity defined as "singleInstance", it does not allow other activities to be part of its task. It is the only activity in the task. If another activity is started, that activity is assigned to a different task, as if it
FLAG_ACTIVITY_NEW_TASK
were configured in theIntent
.Therefore the difference is:
The "singleTask" and "singleInstance" modes differ from each other in only one respect: a "singleTask" activity allows other activities to be part of its task, while a "singleInstance" does not.