安卓:将完成()总是调用的onDestroy()? [英] Android: Will finish() ALWAYS call onDestroy()?
问题描述
简单的问题:你可以肯定的是完成()
将调用的onDestroy()
?我还没有发现任何证实这一点。
简单的问题:你可以肯定的是结束()将调用的onDestroy()
首先,这个回答假设你指的是Android的活动
类和完成()
方法的onDestroy()
生命周期的方法。
第二,它取决于你的定义确定:
-
您进程可能之间终止
完成()
和的onDestroy()
,其原因无关无论是触发调用完成()
-
一个设备制造商或ROM莫德可以介绍一些扭曲的变化,将打破之间的
连接完成()
和的onDestroy()
-
电池可能在
走死在完成()
和的onDestroy()
-
等
三,完成()
没有的通话的的onDestroy()
。你可以告诉大家,通过阅读<一个href="https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/app/Activity.java">the来源$ C $ C 。 完成()
一般的触发呼叫到的onDestroy()
。
一般来说,完成()
将最终导致的onDestroy()
被调用。
Simple question: can you be sure that finish()
will call onDestroy()
? I haven't found any confirmation on this.
Simple question: can you be sure that finish() will call onDestroy()?
First, this answer assumes that you are referring to Android's Activity
class and its finish()
method and onDestroy()
lifecycle method.
Second, it depends upon your definition of "sure":
Your process could be terminated in between
finish()
andonDestroy()
, for reasons independent of whatever is triggering the call tofinish()
A device manufacturer or ROM modder could introduce some screwy change that would break the connection between
finish()
andonDestroy()
The battery could go dead in between
finish()
andonDestroy()
Etc.
Third, finish()
does not call onDestroy()
. You can tell that by reading the source code. finish()
usually triggers a call to onDestroy()
.
Generally speaking, finish()
will eventually result in onDestroy()
being called.
这篇关于安卓:将完成()总是调用的onDestroy()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!