android_onSaveInstanceState的调用
来源:互联网 发布:软件项目进度管理工具 编辑:程序博客网 时间:2024/06/01 10:01
API文档:
You should use the onPause() method to write any persistent data (such as user edits) to storage. In addition, the method onSaveInstanceState(Bundle) is called before placing the activity in such a background state, allowing you to save away any dynamic instance state in your activity into the given Bundle, to be later received in onCreate(Bundle) if the activity needs to be re-created.
Note that it is important to save persistent data in onPause() instead of onSaveInstanceState(Bundle) because the latter is not part of the lifecycle callbacks, so will not be called in every situation as described in its documentation.
Starting with Honeycomb, an application is not in the killable state until its onStop() has returned. This impacts when onSaveInstanceState(Bundle) may be called (it may be safely called after onPause() and allows and application to safely wait until onStop() to save persistent state.
One example of when onPause() and onStop() is called and not this method is when a user navigates back from activity B to activity A: there is no need to call onSaveInstanceState(Bundle) on B because that particular instance will never be restored, so the system avoids calling it. An example when onPause() is called and not onSaveInstanceState(Bundle) is when activity B is launched in front of activity A: the system may avoid calling onSaveInstanceState(Bundle) on activity A if it isn't killed during the lifetime of B since the state of the user interface of A will stay intact.
个人翻译:
任何持久化数据应该在onPause中存储起来。
onPause是activity的生命周期回调函数,onSaveInstanceState()不是。
例如: onPause() 返回/ stay intact
- android_onSaveInstanceState的调用
- 关于公式调用的调用
- 调用门的定义+调用
- 调用门的定义+调用
- 方法参数的调用是值调用而不是引用调用
- C++函数的传值调用&指针调用&引用调用
- 库函数调用和系统调用的区别
- 库函数调用和系统调用的区别
- 委托的异步调用和同步调用
- 系统调用与库函数调用的区别
- 系统调用与函数调用的区别
- 系统调用和库函数调用的区别
- 库函数调用和系统调用的区别
- 各种调用约定的参数调用
- 库函数调用和系统调用的区别
- 系统调用与库函数调用的区别
- 库函数调用和系统调用的区别
- 系统调用与函数调用的区别
- 如何编译单个驱动文件
- 数组反序
- 九城问答系统接口
- oracle的RMAN备份基础知识普及
- Goog drive complex
- android_onSaveInstanceState的调用
- GNU Compile :可执行文件, 静态链接库, 动态链接库
- STL容器特征总结
- poj4474 Scout YYF I(概率dp+矩阵快速幂)
- Code viewer hierarchy
- 初探Hibernate
- 福利到!Rafy(原OEA)领域实体框架 2.22.2067 发布!
- Access restriction: The type JPEGImageEncoder is not accessible due to restriction
- Android通过http协议POST传输方式