简体   繁体   中英

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 eg 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM