gpt4 book ai didi

android - 在 onStop() 或 super.onStop() 返回后 Activity 是否可以被杀死

转载 作者:行者123 更新时间:2023-12-02 02:41:37 26 4
gpt4 key购买 nike

我正在阅读有关 Activity 生命周期方法的文档 here

这是文档中表格的快照。

enter image description here

onStop() 方法在此处被标记为可终止。但是,尚不清楚 Activity 何时可以终止 - 在基础 Activity 返回或派生的 onStop() 之后(扩展的那个)基础 Activity) 返回。

根据下面的引述:

Note the "Killable" column in the above table -- for those methods that are marked as being killable, after that method returns the process hosting the activity may be killed by the system at any time without another line of its code being executed.

对于这个:

For those methods that are not marked as being killable, the activity's process will not be killed by the system starting from the time the method is called and continuing after it returns. Thus an activity is in the killable state, for example, between after onStop() to the start of onResume(). Keep in mind that under extreme memory pressure the system can kill the application process at any time.

感觉是子类的onStop方法的意思,但我还是有疑问。有谁知道是什么意思吗?

请在文档或源代码中提供具体证明。

最佳答案

文档中的另一个声明:

Starting with Honeycomb, an application is not in the killable state until its onStop() has returned.

很明显,函数在到达末尾时返回(在执行完基类和子类的代码之后)。

关于android - 在 onStop() 或 super.onStop() 返回后 Activity 是否可以被杀死,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59120824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com