Lifecycle review

Most readers will be familiar thoroughly with Android Lifecycle. However, it is always useful to review this as it is a super important thing, and there might be some readers who haven't had a chance to know it so well.

Readers will find everything and more in the official documentation page at https://developer.android.com/guide/components/activities/activity-lifecycle.html.

The Android Activity Lifecycle describes an order and conditions on which the special methods are called:

  • onCreate()
  • onStart()
  • onResume()
  • onPause()
  • onStop()
  • onDestroy()

Developers have to override them so that their code can get called at the points in the lifecycle specific to an activity:

In the preceding figure (taken from https://developer.android.com/guide/components/activities/activity-lifecycle.html), we can see the full lifecycle of the activity.

At first, the activity gets created and onCreate() is called. Then, the activity gets started with the onStart() call. After it is started, it usually receives focus and onResume() is called.

Obviously, onPause(), onStop(), and onDestroy() are called at their respective times according to the flow mentioned before. It is worth noting that an Activity that is stopped is not necessarily immediately destroyed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.71.28