Is it possible to finish all activities in current Android task?
Asked
Active
Viewed 1.0k times
13
-
1Please look [here](http://stackoverflow.com/questions/2600969/how-to-finish-series-of-open-sub-activities-from-one-activity) , [here](http://stackoverflow.com/questions/3314838/android-how-to-detect-if-current-stack-of-activities-task-moves-to-background) , [here](http://stackoverflow.com/questions/3825987/how-to-clear-all-activities-in-android-app) and [here](http://stackoverflow.com/questions/6330260/finish-all-previous-activities) – Adil Soomro Oct 28 '11 at 10:37
2 Answers
2
It was already asked here.
But basically there's no such function... Maybe you could keep a collection of all the activities and finish them yourself, but I doubt that's good practice.
Or if all your activities are in the same "stack" you could try the answer given by "user370305".
-
2Yep. I know that there are similar questions. However there is still no answer. FLAG_ACTIVITY_CLEAR_TOP doesn't solve problem, however it is marked there as answer – Alexey Zakharov Oct 28 '11 at 10:55
-
That's true, so if you really want close all activities you'll have to create some sort of task manager that tracks all activities and create a loop to finish them all. Btw, I think [this](http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html) is an interesting blog post about an exit button in android apps (as I think that's what you're aiming for :)). – Glenn85 Oct 28 '11 at 11:56
-1
There is another alternative. Whole application could be done using fragments with single activity. FragmentManager provide full control over fragments and it is possible to finish all of them.

Alexey Zakharov
- 24,694
- 42
- 126
- 197