【发布时间】:2012-07-21 14:37:16
【问题描述】:
假设我们有一个具有默认行为的默认空活动,使用默认意图标志启动。用户按下设备上的后退按钮。活动消失了……但实际上如何?
- 按下后退按钮的行为是否与
finish()相同? - 活动是否被立即销毁(
onDestroy被调用)? - 活动是否保证被销毁,但不能立即销毁?
- 是否有可能该活动不会被销毁并且将来启动该活动时该实例将被重用? (所以只有
onPause和onStop->onStart和onResume被调用?)
我正在寻找一个可靠的答案,所以如果您不确定这里发生了什么,请不要回答。
【问题讨论】:
-
你能把你的代码贴出来,以便我们更好地判断
-
default, empty activity with default behaviour, launched with default intent flags中是否有无法重现的内容?只需在 IDE 中创建一个默认项目。 -
@Chips_100:您提供的链接没有回答这个问题。
-
阅读这个小章节:developer.android.com/training/basics/activity-lifecycle/…
[...]your activity is destroyed due to normal app behavior, such as when the user presses the Back button or your activity signals its own destruction by calling finish().[...]不过我建议阅读整章。
标签: android android-activity onresume onpause ondestroy