Life cycle of Android Activity after pressing Back button

前端 未结 7 809
春和景丽
春和景丽 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:50

    After pressing the back button, Activity B will b destroyed. You see, Android Manages Activities like a Stack(an explanation of a stack). Everytime you start an activity, it pushes into the Activity Stack. So when Activity A calls Activity B, Activity B is now on top of Activity B, and when you press the back button, it also does a pop in the Activity Stack. So in concept, Activity B is gone. Pressing a Home Button is different from pressing back, it pauses the Activity, therefore it still eats a little of the phone's memory.

    Here is a good explanation of how Android Manages Activities.

提交回复
热议问题