Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent multiple instances of an application in recent app screen while using multiple tasks?

Android application having 2 activities other than MainActivity, both activities are having android:launchMode="singleInstance". I navigated to each activity and then i open recent screens it'll show 3 instances of my application, one for application and each one for both activities.

like image 645
Yatish Avatar asked Jan 19 '26 10:01

Yatish


1 Answers

If you really need to create separate tasks (which I doubt, this is a very rare case), then you need to do the following:

  • If you want each task to show up in the list of recent tasks, then you will need a way for the user to differentiate. To do this you should provide a different icon for each <activity> (using android:icon="") and/or a different label for each <activity> (using android:label="").

  • If you only want one task to show up in the list of recent tasks, then you need to set the following on the other <activity> tags in the manifest:

    android:excludeFromRecents="true"

like image 78
David Wasser Avatar answered Jan 21 '26 01:01

David Wasser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!