将活动运行时的onDestroy系统杀呢?系统、onDestroy

2023-09-06 10:02:51 作者:人活一种状态别跟哥谈成败

我想知道,当系统杀死这种意志的活动运行的方法的onDestroy?

I am wondering that will activity run the method "onDestroy" when killed by system?

例如,当活动A的状态的onStop(用户可以直接preSS Home键),同时,系统发现,该内存不够那么系统必须杀死一些后台进程,以保持前台活动ALIFE,说杀系统A.活动

for example, when the state of "activity A" is onStop ( user may press the Home button directly ), at the same time, system find out that the memory is not enough so system have to kill some background processes to keep foreground activity alife, say system kill activity A.

威尔活动运行在这种情况下方法的onDestroy?

Will activity A run the method "onDestroy" in this situation?

推荐答案

这将完全取决于当时的系统状态。文档清楚地说,大约的onDestroy()是:

It will purely depend on the system condition at that time. Docs clearly says about onDestroy() that:

在有些情况下,系统只会杀死活动的  托管进程在不调用它这个方法(或任何其他人),所以  它不应该被用来做是为了保持乾坤  处理过程进入后离开。

There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.

请参阅这里