Now we’re going to take a deeper look on the Hello Android application and know what each line of code exactly means
The file contains the following code:

import android.os.Bundle;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

  1. The first line is the package name of the application.
  2. Lines 3,4 are import statements of two libraries():
  3. Line 6 is the declaration of the HelloAndroid class which extends from
    , Activity represents the User interface of your application much like windows or web forms.
  4. Our class contains one function which is onCreate(Bundle savedInstanceState). This function is called when the activity is first created, it should contain all the initialization and UI setup.
    This function has a parameter savedInstanceState of type Bundle
    this object holds the activity’s previously saved state if exists (similar to view state concept)
  5. Line 10 calls the super class’ OnCreateMethod with the activity’s

  6. Line 11 calls
    method which dsiplays the layout definition in main.xml file in res/layout directory by accessing a reference to it from the R class
    This method is required to display the user interface, if the activity does not include this function then it would display a blank screen

The basic android application with only one view consists of a class that extends the Activity class. This class preserves the activity frozen state (like viewstate in and it displays the UI defined in xml file or defined explicitly programmatically.