I want to show 2 different activities of one app at recent apps by calling 2 different activities like the image below. How can I do that?
Asked
Active
Viewed 757 times
3
-
Hello again :) Please check if this is what you're looking: https://stackoverflow.com/questions/34866998/how-to-keep-multiple-activities-of-the-same-app-in-the-recent-apps-list – ʍѳђઽ૯ท Oct 03 '18 at 15:17
-
1Thank youu it is true answer again – begiNNer Oct 03 '18 at 15:55
1 Answers
4
For API Level 21 or above, it can simply be accomplished by setting the flag Intent.FLAG_ACTIVITY_NEW_DOCUMENT in the intent.
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
If your minimum API level is less than 21, you can make use of the activity attribute taskAffinity
in the manifest.
<activity
android:name="com.example.ActivityOne"
android:taskAffinity="app.two" />
<activity
android:name="com.example.ActivityTwo"
android:taskAffinity="app.two" />
After setting different affinities, launching the activities as singleInstance
or setting the flag Intent.FLAG_ACTIVITY_NEW_TASK will make the two activities appear separately in the recents.
<activity
android:name="com.example.ActivityTwo"
android:launchMode="singleInstance"
android:taskAffinity="app.two" />
OR
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Nabin Bhandari
- 15,949
- 6
- 45
- 59
-
1Thank you for answering, but my minSdkVersion is 16 and taskAffinity is working. – begiNNer Oct 03 '18 at 15:56
-