Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

(I searched quite a bit, but there seems no exact answer for this.)

Let's say there's an app. We can push a button to start another activity.

Like this: Activity1 -> Activity2 -> Activity3

If we use the 'back' button, it calls the finish(), so each activity's onDestroy() gets called.

But, if we close the app(by pushing the 'overview' button and then swipe the app out),

only the Activity1's onDestroy() gets called.

  1. Why the onDestroy() of other activities are not called?
  2. Does it mean that other activities are alive until the system kills them? (If the system has enough resources, they are not destroyed?)
question from:https://stackoverflow.com/questions/66065114/why-only-the-first-activitys-ondestroy-is-called-not-other-activities

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
275 views
Welcome To Ask or Share your Answers For Others

1 Answer

Ideally when you force close the App from overview, it kills the entire app process and all the activities are destroyed, and your activity stack root's(which is ActivityA) onDestroy method is called and for other activities the method won't be triggered but the stack itself gets destroyed along with the process. Nothing will be alive once the process is destroyed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...