Jan Drozen
Jan Drozen

Reputation: 984

Removing activity from recent apps keeping older one

I have this challenge with my Android APP:

I have and "dialog" - I mean an activity created as a dialog. Now, user presses the home button and leaves the app ~ later holds the home button and displays the Recent apps list. He will see the dialog as the last activity of my app. However, I don't want to display this activity on the "stack".

I tried the exceludeFromRecentApps (or similar name) and this one enabled removes whole app from the list. But I want to have dialog's parent activity displayed in the list. I tried something with overriding the onResume, onPause and onStop methods, but no effect for me, since instance-level variables may be discarded (?). I believe thats trivial problem, but I wasn't able to google working solution.

Lot of thanks!

Upvotes: 0

Views: 1196

Answers (2)

mzain
mzain

Reputation: 383

android:noHistory="true"
android:taskAffinity=""
android:excludeFromRecents="true"

for your case, first you need to separate your dialog activity by "taskAffinity" tag. Then you need "excludeFromRecents" tag in you AndroidManifest.xml to remove is from recent list.

Upvotes: 4

An SO User
An SO User

Reputation: 25028

Like Hoan Nguyen said, you need to use the finish() method but know that the finish() method does not guarantee that the Activity will be finished.

Upvotes: 0

Related Questions