Activity 在 onStop() 或 super.onStop() 返回后是否可杀死 [英] Is Activity killable after onStop() or super.onStop() returns

查看:37
本文介绍了Activity 在 onStop() 或 super.onStop() 返回后是否可杀死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

onStop() 方法在那里被标记为可杀死.但是,不清楚 Activity 何时可以杀死 - 在基本 Activity 返回或派生的 onStop() 之后(扩展的那个)基础 Activity) 返回.

根据以下引用:

<块引用>

注意上表中的Killable"列——对于那些被标记为可杀死的方法,在该方法返回之后,承载活动的进程可能会在任何时候被系统杀死,而其另一行代码不被执行.

还有这个:

<块引用>

对于那些没有被标记为可杀死的方法,活动的进程不会被系统从调用该方法的时间开始并在它返回后继续进行.因此,活动处于可终止状态,例如,在 onStop() 之后到 onResume() 开始之间.请记住,在极端内存压力下,系统可以随时终止应用进程.

感觉就像子类的 onStop 方法的意思,但我仍然有疑问.有谁知道是什么意思?

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

解决方案

文档中的另一个声明:

<块引用>

从 Honeycomb 开始,应用程序在其 onStop() 返回之前不会处于可终止状态.

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

I'm reading the documentation about Activity lifecycle methods here

And here's a snapshot from the table in the documentation.

onStop() method is marked as killable there. However, it's not clear when exactly Activity is killable - after onStop() of the base Activity returns or of the derived one (the one extending the base Activity) returns.

According to the quote below:

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.

And to this one:

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.

It feels like the subclass's onStop method is meant but still I have a doubt. Does anyone know which one is meant?

Please provide either a specific proof in the documentation or in the source code.

解决方案

Another statement from docs:

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

It's clear that a function returns when it reaches the end (after the base and subclasses' code have been executed).

这篇关于Activity 在 onStop() 或 super.onStop() 返回后是否可杀死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆