最近在看Android开发文档,摘录一些关键的段落,方便查找记忆。

Because onPause() is the first of the three(onPause(),onStop(),onDestroy()), once the activity is created, onPause() is the last method that's guaranteed to be called before the process can be killed—if the system must recover memory in an emergency, then onStop() and onDestroy() might not be called. Therefore, you should use onPause() to write crucial persistent data (such as user edits) to storage. However, you should be selective about what information must be retained during onPause(), because any blocking procedures in this method block the transition to the next activity and slow the user experience.

Note: Because onSaveInstanceState() is not guaranteed to be called, you should use it only to record the transient state of the activity (the state of the UI)—you should never use it to store persistent data. Instead, you should use onPause() to store persistent data (such as data that should be saved to a database) when the user leaves the activity.

    关键的持久数据应该在onPause()方法中保存,因为onPause()方法是进程被杀死之前保证会执行的最后一个方法。当然保存的数据必须慎重,因为如果方法阻塞,会影响系统响应时间,影响用户体验。

更多相关文章

  1. android 中让activity全屏幕显示
  2. Android添加单元测试的方法与步骤
  3. Android(安卓)Studio无法执行Java类的main方法问题及解决方法
  4. android 绘图
  5. Android获取屏幕宽度的4种方法
  6. 国内目前最全面的介绍——Android中的BroadCastReceiver
  7. android 中让activity全屏幕显示
  8. Android优质学习方法
  9. android 开发收银系统,弹出键盘固定界面UI的方法

随机推荐

  1. android之使用Html5开发
  2. Android助力国产手机,诺基亚会否噩梦不断?
  3. 《Android移动应用基础教程》(Android Stu
  4. [Android算法] Android蓝牙开发浅谈
  5. android icon 设计
  6. android 依赖工程 Android 工程引用其他L
  7. Android(安卓)API Guides---Debugging We
  8. Android使用JNI实现Java与C之间传递数据
  9. android google 分屏 多窗口 按home键界
  10. Android HAL实现的三种方式(1) - 基于JNI