android中的捆绑包是否永久保存活动状态? [英] Are the bundles in android permanent in saving activity states ?
问题描述
当我想保存活动的某些状态行为时,文档说我们应该实现OnSaveInstanceState和OnReceiveInstanceState.
When I want to save some state behavior of the activity, The docs says that we should implement OnSaveInstanceState and OnReceiveInstanceState.
他们说,即使销毁或重启后,这也将保存活动状态.我更关心销毁(活动已完全消失),这是否意味着捆绑包被认为是永久性的?
They say that this will save the activity state even after destroy or restarts. I care more about destroy (the activity is completely gone) , does that mean the bundles are considered persistent ?
当我打开pdf阅读器时,将其关闭并再次打开,我看到它在我所在的页面中打开.这是使用Bundles或oth
when I open a pdf reader, clost it and open it again i see that it opens in the same page I was in. is this implemented using Bundles or oth
推荐答案
您可以 sorta 考虑 SavedInstanceState()
是永久性的,但不建议使用它来保存与应用程序相关的内容数据以持久的方式存在,因为它不能保证被调用,并且作者自己也不建议这样做.
You can sorta consider SavedInstanceState()
permanent but it's not recommended to use it for saving application related data in a persistent manner as It's not guaranteed to be called and it's not recommended by the authors themselves.
因此,仅将它们用于保存用户界面状态更改(背景颜色,当前选定的项目,..),并使用其他持久性方法,例如:SharedPreferences,Files和SQLite.
so, Only use them for saving user interface state changes (background color, currently selected items ,..) and use other method for persistence like : SharedPreferences, Files and SQLite.
这篇关于android中的捆绑包是否永久保存活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!