android 建议在onPause和onStop处理的事情
如下android doc里面的原文
Generally, you shouldnotuseonPause()
to store user changes (such as personal information entered into a form) to permanent storage. The only time you should persist user changes to permanent storage withinonPause()
is when you're certain users expect the changes to be auto-saved (such as when drafting an email). However, you should avoid performing CPU-intensive work duringonPause()
, such as writing to a database, because it can slow the visible transition to the next activity (you should instead perform heavy-load shutdown operations duringonStop()
).
一般来说,我们不需要再onPause的时候将例如一个表单内容保存到物理内存中。只有当你确认一个用户引发的变化是必须被自动保存的时候,例如正在看一份邮件时,你就需要在onPause时保存这个邮件信息了。然而,在onPause的时候只适合做一些占用cpu极短时间的动作,例如写数据库就是一个耗时的工作,你应该在onStop的时候干这个事情
更多相关文章
- Android中InstanceState()使用详解
- android edittext不弹出软键盘
- android自动化(2)
- android Sqlite多线程访问异常解决方案
- android 判断sdcard是否存在,以及写入权限
- 【Android自学笔记】Android中的Log小技巧
- android按钮的操作例子,简单大家看明白_基础篇
- ClassCastException android.view.viewgroup.$layoutParam
- Android之使用RatingBar设置游戏难度并保存