I would like to know how can I clean all previous activities of the stack (except the new one), but I want that in Android API 10 (Android 2.3.3).
Guided with this answer, I know it is not directly possible because the flag dedicated to do that exists since API 11.
But I would like to know if this is possible maybe with some compatibility or if someone has any solution.
Thanks in advance.
On way to do this is to always start your activities using
startActivityForResult()
. In the case where you want to clean the activity stack have the current activity callsetResult(RESULT_CANCELED)
and then callfinish()
. In all activities (except your main or "root" activity) have the following method:This will finish all activities in the stack.
You could add in manifest file android:noHistory="true" to each activity that you don't want to keep in the stack