Friday 12 March 2021

Where should I add android:taskAffinity when I launch existing instance of an activity from static shortcut in Android Studio?

As the static shortcuts will always have FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK set, I've created TempActivity which is an invisible Activity i.e It'll start MainActivity and then calls finish(). And also as suggested in developer docs SecondActivity has android:taskAffinity="" in the app's AndroidManifest.xml file.

I have read Manage shortcuts and How to launch existing instance of an activity from static shortcut.

You can see Image A and Image B. There are different opinions.

Where should I add android:taskAffinity when I launch existing instance of an activity from static shortcut in Android Studio? MainActivity or TempActivity ?

Image A

enter image description here

Image B

enter image description here



from Where should I add android:taskAffinity when I launch existing instance of an activity from static shortcut in Android Studio?

No comments:

Post a Comment