0

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!

Jan Drozen
  • 894
  • 2
  • 12
  • 28

2 Answers2

4
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.

mzain
  • 383
  • 2
  • 9
  • noHistrory works most of case but not in my case. i am opening dialog activity from a service while my main activity already in background. – mzain Mar 03 '14 at 12:52
0

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.

An SO User
  • 24,612
  • 35
  • 133
  • 221
  • I tired this approach and for me is not working. The opening activity is finished, however, the parent one never appears. I use startActivityForResult to run the dialog. I checked I have no noHistory enabled in Manifest. So I am confused about it..:( – Jan Drozen Aug 18 '13 at 20:01