-5

In Android activity lifecycle, do onStop() and onDestroy() always called? Why? Moreover, please named the state definitely called in activity lifecycle? Many thanks

Truong Vu
  • 204
  • 4
  • 14

1 Answers1

1

I have attached an image of the Activity lifecycle. When an activity is first run, it will call onCreate(), and after it is created, it will call onStart() to get the activity started which proceed on to onResume(). When the application enter another activity, the previous activity will be onPause() and onStop if I'm not wrong.

If you exit the activity by pressing the back button (destroying), it will be onPause() -> onStop() -> onDestroy()

If you enter activity B from activity A, it will be onPause() -> onStop()

If you enter activity B, it will be depending on whether the activity is destroyed or it just stop. If it's stop, it will be onStart() -> onResume().

If it's destroyed, it will be onCreate() -> onStart() -> onResume()

Android Activity Lifecycle

(diagram source)

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Ophitect
  • 543
  • 4
  • 18