Activity生命周期方法

Activity lifecycle:activity stack
生命周期方法:
onCreate() :全局初始化
onStart()
onResume()
onPause()
onStop()
onDestory():释放资源。

1 The entire lifetime of an activity happens between the first call to onCreate(Bundle) through to a single final call to onDestroy().
2 The visible lifetime of an activity happens between a call to onStart() until a corresponding call to onStop().   //onRestart()
3 The foreground lifetime of an activity happens between a call to onResume() until a corresponding call to onPause().
4  onSaveInstanceState(Bundle) 保存动态数据到Bundle里;不会每次都被调用
   onPause()持久化数据
--------------------------------------------------------------------------------------------------------------------------------------
Process Lifecycle
1 The foreground activity
2 A visible activity
3 A background activity
4 An empty process

 

 

 在调用startActivityForResult()调用了onSavedInstanceState(),onPause(),

 [在另一个Activity的onCreate()方法运行以后] onStop()
 回来的时候依次调用了onActivityResult(),onRestart(),onStart(),onResume()

 

当你的程序中某一个Activity A 在运行时中,主动或被动地运行另一个新的Activity B
这个时候A会执行 onSaveInstanceState 方法。

如果你返回A时,系统已经回收过。 那么要重新 执行 A 带savedInstanceState参数的 onCreate方法。

你可能感兴趣的:(Activity生命周期方法)