安卓:将完成()总是调用的onDestroy()? [英] Android: Will finish() ALWAYS call onDestroy()?

查看:104
本文介绍了安卓:将完成()总是调用的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() and onDestroy(), for reasons independent of whatever is triggering the call to finish()

  • A device manufacturer or ROM modder could introduce some screwy change that would break the connection between finish() and onDestroy()

  • The battery could go dead in between finish() and onDestroy()

  • 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屋!

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