标签:android des blog http strong os
Actiivity 生命周期,如下图所示: onCreate onStart (onRestarted) onResume onPaused(to onResume(User navigates to the activity)) onStop onDestroy
onCreate 方法: 一定要实现OnCreate方法,初始化 组件和布局。
onPause 方法:用户离开activity是的第一个被触发的方法。
onDestroy 方法: 系统也许直接kill了process,这个方法未必会被调用。
An activity can exist in essentially three states:
Activity
object is retained in memory, it maintains all state and member information, and remains attached to the window manager), but can be killed by the system in extremely low memory situations.Activity
object is retained in memory, it maintains all state and member information, but is not attached to the window manager). However, it is no longer visible to the user and it can be killed by the system when memory is needed elsewhere.
两个Activity跳转时的生命周期方法调用顺序, 例如 Activity A 跳转到 Activity B:
onPause()
method executes. //先执行A的onPause方法onCreate()
, onStart()
, and onResume()
methods execute in sequence. (Activity B now has user focus.) //Activity B‘s onCreate、onStart、onResume方法onStop()
method executes. // 执行A的onStop方法
综上,如果有数据交换、交互,请在A的onPause里面执行,否则B启动了也找不到新数据。
标签:android des blog http strong os
原文地址:http://www.cnblogs.com/amosleaf/p/3756238.html