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

一个人想着一个人 提交于 2019-12-07 10:08:46

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6045558/android-how-to-return-to-activity-with-nohistory-attribute-after-onstop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!