Android Activity Class


Activities are the primary class for interacting with users.

Activity interacts with the user by acting as a visual interface.

Every activity does only one thing at a go say for example making a call, sending an SMS.

And we create multiple activities combining them together to create a single application.

This is what helps the user to navigate through the application.

Android supports navigation through activities



A Task is a collection of related activities.

The activities in the task needn’t be a part of the same application.



Everytime an activity is launched; it is being pushed to the top of the backstack.

And the activity gets popped off the backstack only after its being destroyed.



An activity can be in any of the following states

State Description
Running When an activity interacts with the user i.e., when it is visible
Paused When an activity is still visible(instance is still running) but user not interacting with it and the activity can be killed (by the system)
Stopped When the activity is not visible(instance is still running) but can be killed by the system
Killed When the activity is not visible and is  terminated  by the system

Android calls specific activity methods and passes activity lifecycle state changes to the activity.

Method Description
onCreate() This method is called to create and initialize the activity
onStart() This method is called when the app is about to be  visible
onResume() This method is called when activity becomes visible  and the user interacts with the activity
onPause() This method is called when another activity occupies the foreground
onRestart() Sometimes, this method is called when is app is about to start again
onStop() This method is called when the activity is about to be stopped i.e. no longer visible again
onDestroy() This method is called when the activity is terminated


Activity life cycle


Consider the previous simple application when the application is launched

  • Android calls the activity’s onCreate method
  • And then android calls the activity’s onStart() method
  • Then it Resumes by calling onResume() method
  • Then the activity’s interface appears on the screen
  • And finally the activity will begin to terminate by calling onStop() and followed by onDestroy()
  • The entire lifetime of the activity is from when it’s created till when it’s destroyed. e., the activity is visible only from during this period.


Latest posts by abirami vijayakumar (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *