Android Activity Life cycle

Android Activity Life cycle is controlled by 7 methods of class. The android Activity is the subclass of ContextThemeWrapper class.

An activity is the single screen in android. It is like window or frame of Java.

By the help of activity, you can place all your UI components or widgets in a single screen.

The 7 life cycle method of Activity describes how activity will behave at different states.

Android Activity Life cycle methods

Let's see the 7 life cycle methods of android activity.

Method Description
onCreate called when activity is first created.
onStart called when activity is becoming visible to the user.
onResume called when activity will start interacting with the user.
onPause called when activity is not visible to the user.
onStop called when activity is no longer visible to the user.
onRestart called after your activity is stopped, prior to start.
onDestroy called before the activity is destroyed.

android life cycle of activity

UI Widgets

The individual elements of an Android UI are arrenged on screen by means of a variety of Layout Managers derived from the ViewGroup class.

Android components used to create UIs. You all learn how to use layout, Fragments, and Views to create functional UIs for your Activities.

As if a devices can function if it has no style. As if a device can be called stylish that does not function superbly, beauty matters .

Edit Text

An editable text entry box that accepts multiple entry, word awrapping,and hint text.

Text View

A standerd read only text lable that supports multiple display, string formating , and automatic word wraping.


A standard push button.

Check box

A two-state button respresented by a checked or unchecked box.

Radio Button

A two state grouped button. A group of these presents the user with a number of possible options, of which only one can be enabled at a time.

List View

A View Group that creates and manages a vertical list of Views, displaying them as rows within the list. The simplest List View display the toString value of each object in an array, using a Text View for each item.


A Text View extension that implements a simple count-up timer.


A composite control that display a Text View and a associated List View that lets you select an item from a list to display in the textbox.

Toggle Button

A two state button that can be used as an alternative to a check box. Its particularly appropriate whare pressing the button will initiate an action as well as changing a state .

Image Button

A push button for which you can specify a customized background image.

Check Box

A two state button represented by a checked or uncheked box

view Flipper

A View Group that lets you define a collection of Views as a horizontal row in which only one View is visible at a time , and in which transitions between visible views can be animated.

Video View

Handles all state management and display Surface configuration for playing video more simply from within your Activity.

QuickContact Badge

Display a badge showing the image icon asssinged to a contact you specify using a phone number, name , email address, or URI.

View Pager

Released as part of the Compatibility Package, the View Page implements a horizontally scrolling set of View similar to the UI used in Google Play and Calender.

Android Activity Lifecycle Example

In this example, we are displaying the content on the logcat.

package com.javatportal.activitylifecycle;  
import android.os.Bundle;  
import android.util.Log;  
import android.view.Menu;  
public class MainActivity extends Activity {  
    protected void onCreate(Bundle savedInstanceState) {  
        Log.d("lifecycle","onCreate invoked");  
    protected void onStart() {  
         Log.d("lifecycle","onStart invoked");  
    protected void onResume() {  
         Log.d("lifecycle","onResume invoked");  
    protected void onPause() {  
         Log.d("lifecycle","onPause invoked");  
    protected void onStop() {  
         Log.d("lifecycle","onStop invoked");  
    protected void onRestart() {  
         Log.d("lifecycle","onRestart invoked");  
    protected void onDestroy() {  
         Log.d("lifecycle","onDestroy invoked");