Life cycle of Android Activity after pressing Back button

前端 未结 7 803
春和景丽
春和景丽 2020-12-07 19:17

I am little confused between the life cycle of two activities.

Suppose I have Activity A and Activity B.

B is called From A i.e A ----> B.

7条回答
  •  执笔经年
    2020-12-07 19:57

    Activity B will be destroyed and will no longer remain in memory.

    For more information please visit the official documentation for android and have a look at the activity life cycle figure.

    Once you press the back key the activity's onDestroy() method will be called and the activity will be flushed out of the memory. You will then be required to restart the activity by calling the startActivity() method which will in turn call its onCreate() Method.

提交回复
热议问题