Debug and fix an activity lifecycle issue (Associate Android Developer Certification)

It is very important to understand lifecycle of Activity for Android developer.
Android-Activity-Lifecycle

When app starts:

  1. onCreate
  2. onStart
  3. onResume

When home button clicked:

  1. onPause
  2. onStop

On reopening app:

  1. onRestart
  2. onStart
  3. onResume

When back button clicked:

  1. onPause
  2. onStop
  3. onDestroy