I want to know what is the default task affinity for singleInstance activity?
Since each singleInstance Activity opens up as root activity in a new task. and there is no need to declare android:taskAffinity.
See I have read the developer guides and docs for android activity.
https://developer.android.com/guide/components/activities/tasks-and-back-stack and https://developer.android.com/guide/topics/manifest/activity-element.html#aff
<activity android:name=".MainActivity"
android:launchMode="singleInstance"
>
</activity>
I want to know the taskAffinity - string literal for that task in which singleInstance activity resides as root.
The default taskAffinity is the package name of the app from the manifest <package> tag.
This is for all activities, no matter what the launch mode is.
This is why a lot of developers have problems using the special launch modes singleInstance and singleTask, because taskAffinity trumps launch mode, so sometimes those activities will NOT be launched in a new task, but simply launched into the existing task as if the launch mode were "standard".
The default taskAffinity of all activities including singleInstance activity will be the same (which is the applicationId), but the taskId of singleInstance activity will be different (unique) than other activities; but the users cannot see and switch tasks from the recents.
Setting a different taskAffinity to a singleInstance activity will give it that taskAffinity value and additionally allow the users to see and switch between the tasks from the recents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With