首页 > 移动平台 > 详细

Android finish后没有执行 onDestory()

时间:2015-08-06 14:43:16      阅读:505      评论:0      收藏:0      [点我收藏+]

如果要保存数据或者有数据相关操作,最好在onPause函数中,因为onDestroy的函数有可能不执行。

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.

上面是官网的话,意思大概是,有很多情况下系统会简单的杀死这个Activity的宿主进程而不调用它的onDestroy方法,所以在这个方法中不要做任何有关保留数据或者状态的相关操作。

技术分享

 

这张是官网Activity的生命周期图,我们可以看到Activity有两个出口,onStop后有可能直接到 App process killed,而不执行onDestroy函数。

技术分享

技术分享

技术分享

Android finish后没有执行 onDestory()

原文:http://www.cnblogs.com/maydow/p/4707761.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!