我想做的就是在按下主页按钮时调用 onFinish(),我想这样做所以我总是在打开我的应用程序时进入主要 Activity ,我不希望用户跳回到他离开的地方(我知道在大多数情况下这是一个糟糕的概念,但对于我的应用来说,始终进入主要 Activity 更有意义)
谢谢!
最佳答案
您真正想要发生的是您的所有子 Activity 都具有 android:noHistory=true 属性。
http://developer.android.com/guide/topics/manifest/activity-element.html#nohist
android:noHistory : Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it's no longer visible on screen — "true" if it should be finished, and "false" if not. The default value is "false".
A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it.
This attribute was introduced in API Level 3.
关于android - 使主页按钮调用 onFinish(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4389343/