Reputation: 21
I know this has been answered earlier but I could not find the appropriate solution which fits in my case. I have an app with multiple activities in it. On the first Activity, when the user presses the back button, a close confirmation dialog box is opened to ask the user for confirmation.
When the user presses 'Yes', the application is closed but it is still in the recent apps list.
What I want is to remove it from the recent apps list as well but only when the user comes out of the app using this Close dialog. i.e. If the user presses the home button or Apps List button, the app should still be listed in the recent apps list.
I tried using android:excludeFromRecents="true"
property for this activity but it excludes the complete app from the recent apps list even if any other Activity is being worked upon.
In short, I want to remove the app from the recent apps list on a button click.
Upvotes: 1
Views: 1773
Reputation: 1674
U can use finishAndRemoveTask()
if u want to remove your own activity from recent tasks.
Upvotes: 2