-3

I have MainActivity and SecondActivity in my practice app to understand activity lifecycle. I am clicking the overview button closing the app once it is in MainActivity ( see below which does not call its onDestroy()) enter image description here

and closing the app once I navigate to the SecondActivity through a button click(in this case MainActivity's onDestroy() is called, image below)

enter image description here

I am not sure how important understanding this scenario is, as I am preparing for my interviews. Any advise is much appreciated.

askatral
  • 133
  • 8

1 Answers1

0

There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away. so,you can't be always sure, that this method will be called

here is the google docs

https://developer.android.com/reference/android/app/Activity.html#onDestroy%28%29*

Dheeraj Joshi
  • 1,522
  • 14
  • 23