Life Cycle of Android Activity

Life Cycle of Android Activity

Written by Ayushs | Published 6 months ago

Android has been the best-selling OS worldwide on smartphones since 2011 and on tablets since 2013. As of May 2017, it has over two billion monthly active users, the largest installed base of any operating system, and as of January 2021, the Google Play Store features over 3 million apps.


It is free and open-source software with its source code known as Android Open Source Project (AOSP) primarily licensed under the Apache License. About 70 percent of Android smartphones run Google's ecosystem; competing Android ecosystems and forks include Fire OS (developed by Amazon) or LineageOS.


Android Activity Lifecycle


Android Activity Lifecycle is controlled by 7 methods of the android.app.Activity class. The android Activity is the subclass of ContextThemeWrapper class.


An activity is a single screen in android. It is like a window or frame of Java. With the help of activity, you can place all your UI components or widgets on a single screen.


The 7 lifecycle method of Activity describes how the activity will behave at different states. Find more on InterviewBit


  • OnCreate(): It is called when activity is created. Using this, the views are created and data is collected from bundles.
  • OnStart(): It is called if the activity is becoming visible to the user. It may be succeeded by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.
  • OnResume(): It is called when the activity will start an interaction with the user.
  • OnPause(): This is called when the activity is moving to the background but hasn’t been killed yet.
  • OnStop(): This is called when an activity is no longer visible to the user.
  • OnDestroy(): This is called when the activity is finished or destroyed.
  • OnRestart(): This is called after the activity has been stopped, prior to it being started again.

RELATED BLOGS