onStop与onDestroy [英] onStop vs onDestroy
问题描述
我曾尝试确切地研究过何时调用onDestroy方法来进行活动,但是我已经阅读了一些令人困惑和矛盾的信息.通常,我的问题是:在什么情况下onDestroy方法实际上是在活动上调用的?更具体地说,如果我有两个活动,即活动A和活动B,如果活动A正在运行并且我创建了一个意图并切换到活动B,则活动A仅停止还是被销毁?
I have tried to research exactly when the onDestroy method is called for an activity, but I've read some confusing and conflicting information. In general, my question is: under what circumstances is the onDestroy method actually called on an activity? More specifically, if I have two activities, activity A and activity B, if activity A is running and I create an intent and switch to activity B, is activity A only stopped, or is it destroyed?
推荐答案
在您的示例中,活动A已停止,并且可能被系统破坏
每个上方
documentation
链接注意:
In your example the Activity A is stopped and could be destroyed by the System
Note per
documentation
link above:
…不要指望[onDestroy()
]被称为保存数据的地方……[请参见onPause()
或onSaveInstanceState(Bundle)
.
…do not count on [onDestroy()
] being called as a place for saving data … [see] eitheronPause()
oronSaveInstanceState(Bundle)
.
这篇关于onStop与onDestroy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!