Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to return to Activity with "noHistory" attribute after onStop?

I was looking for a way to delete a certain activity from history stack, and found a solution here (Wakkas's anwer). However, if I close the app with this activity opened e.g. by pressing the home button, and later return to it, the activity is not restored.

If I remove the "noHistory" attribute, it is coming back and also restored after a kill.

Is there a way to make it not appear on the history stack (= don't want to come back to it by pressing the back button in next activity) without this behavior?

Kind regards, jellyfish

like image 472
jellyfish Avatar asked Dec 21 '22 13:12

jellyfish


1 Answers

I don't think so - leaving the activity via the "Home" button and opening a new activity will have the same effect: if your activity is not in the history stack, it should not be restored.

Instead of using the "noHistory" attribute, couldn't you just call finish() as you launch your next activity? It should not re-appear when you then hit the "back" button.

like image 74
Nathan Fig Avatar answered May 14 '23 11:05

Nathan Fig