我必须坚持的活动数据时的onStop()触发? [英] Must I persist Activity data when onStop() fires?

查看:211
本文介绍了我必须坚持的活动数据时的onStop()触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得对于活动周期的官方文档不明。它是散落着的词语,如可能的这使我不知道我的必须的。当涉及到的onStop() - 方法,该文件说以下内容:

I find the official documentation regarding the Activity lifecycle unclear. It's littered with words such as should and might which makes me wonder what I must. When it comes to the onStop()-method, the documentation says the following:

注:由于系统保留在系统内存中的活动实例,当它停止时,它可能是你并不需要实现的onStop()和onRestart()(甚至ONSTART()方法在所有

Note: Because the system retains your Activity instance in system memory when it is stopped, it's possible that you don't need to implement the onStop() and onRestart() (or even onStart() methods at all.

这是的可能的?难道我还是做我不?可以说我有依赖定义为活动类的私有变量的一些标准的Java对象的某些自定义组件。我需要坚持的onStop法这些对象?我可的保证的这些变量都当onRestart相同的内容()火?

It's possible? Do I or do I not? Lets say I have some custom components that rely on some standard Java objects defined as private variables in the Activity class. Do I need to persist these objects in the onStop-method? Can I be guaranteed that these variables have the same content when on onRestart() fires?

编辑:链接表在回答引用。

推荐答案

有关的具体问题,你需要考虑的 killable 的列在总览表格。机器人(pre-蜂窝)认为您的活动killable的onPause()被调用后。所以,如果你需要的持久性进行通话,并要处理,关于活动的水平,这就是你保存你的活动状态。

For your specific question, you need to consider the killable column in the overview table. Android (pre-Honeycomb) considers your Activity killable after onPause() has been called. So if you need persistence for the next call, and you want to handle that on the Activity level, that's where you save your activity state.

这篇关于我必须坚持的活动数据时的onStop()触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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