生命周期
LRU Cache
一个list 存放最近使用的应用的清单。
Application 生命周期
onCreate() 开启应用第一个组件之前调用。
onLowMemory() android 系统请求这个应用释放内存是调用。
onTrimMemory()
onTerminate() 仅在测试时有效。
onConfigurationChanged()
配置改变是调用。
Activity 生命周期
四个状态:
1.运行 :Activity 正在使用,与用户交互。
2.暂停 :Activity 可见, 但部分被掩盖,不能操作。
3.停止 :Activity 不可见。
4.死亡 :被系统 以finshed()方法 杀死。
重要的方法:
![Activity life cycle](http://www.vogella.com/tutorials/AndroidLifeCycle/img/xactivity_lifecycle10.png.pagespeed.ic.fPEkTDwujN.png)
![Activity life cycle](http://www.vogella.com/tutorials/AndroidLifeCycle/img/xactivity_lifecycle10.png.pagespeed.ic.fPEkTDwujN.png)
The
onPause()
method is typically used to stop framework listeners and UI updates. The
onStop()
method is used to save application data. These methods are guaranteed to be called before the activity is terminated。
one Activity 到 two Activity 时:
one create-->one start-->one resume--one pause-->two create-->two start--two resume-->one stop
two activity 按Back键 返回 one activity
two finish-->two pause-->one restart-->one start-->one resume-->two stop-->two destory
one activity 按Back键 返回
one finish-->one pause-->one stop-->one destory