当我们去另一个活动并通过" finish();"或者android的后退按钮,会发生什么?是使用oncreate()方法重新加载的活动还是恢复到调用活动的先前状态?
答案 0 :(得分:0)
onResume()
方法。
答案 1 :(得分:0)
活动A和活动B,
当您从活动A转移到活动B时,生命周期如下
Activity A
--------------------
onCreate() //A
onStart() //A
onResume() //A - here user can interact with UI(buttons,views), user click button and it moves to second activity
onPause() //A
--------------------
onCreate() //Activity B
onStart() //B
onResume() //B
--------------------
onStop() //A - onStop() of Activity A is called after onResume() of Activity B
Now user presses back button in Activity B, then lifecycle as follows
onPause() //B
-------------------------------
onStart() //A
onResume() //A
onStop() //B
onDestroy() //B
这是两个活动之间的生命周期流程