0

我有一个 android 要求,我创建了一个类似结构的表单,有单选按钮、编辑文本等。当用户在表单中输入一半并说通过后退按钮或电池关闭离开页面时。当他返回表格时,应该会重新出现半填表格的相同状态。请建议android是否具有保存表单状态并在用户重新访问时恢复的内部功能。此外,存储的内容应该只保存特定的持续时间,比如一小时,之后应该出现新的表格。请帮助我开始使用可能的方法。

4

1 回答 1

0

I recommend reading the Android Activity lifecycle. From the webpage:

"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. See the Process Lifecycle section for more information on how the lifecycle of a process is tied to the activities it is hosting. 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."

于 2013-04-08T03:47:41.123 回答