in Android by

Internal Details of Hello Android Example

► Click here to show 1 Answer

0 votes

How to make android apps

In this page, you will know how to create the simple hello android application. We are creating the simple example of android using the Eclipse IDE. For creating the simple example:

Create the new android project

Write the message (optional)

Run the android application

Hello Android Example

You need to follow the 3 steps mentioned above for creating the Hello android application.

1) Create the New Android project

For creating the new android studio project:

1) Select Start a new Android Studio project

hello android example

2) Provide the following information: Application name, Company domain, Project location and Package name of application and click next.

hello android example 2

3) Select the API level of application and click next.

hello android example 3

4) Select the Activity type (Empty Activity).

hello android example 4

5) Provide the Activity Name and click finish.

hello android example 5

After finishing the Activity configuration, Android Studio auto generates the activity class and other required configuration files.

Now an android project has been created. You can explore the android project and see the simple program, it looks like this:

hello android example 5 

2) Write the message

File: activity_main.xml

Android studio auto generates code for activity_main.xml file. You may edit this file according to your requirement.

<?xml version="1.0" encoding="utf-8"?>  

< xmlns:android="""










        android:text="Hello Android!"  




        app:layout_constraintTop_toTopOf="parent" />  






Android application contains different components such as java source code, string resources, images, manifest file, apk file etc. Let's understand the project structure of android application.

Project Structure of Hello Android example

Java Source Code

Let's see the java source file created by the Eclipse IDE:


  1. package com.example.helloandroid;  
  2. import android.os.Bundle;  
  3. import;  
  4. import android.view.Menu;  
  5. import android.widget.TextView;  
  6. public class MainActivity extends Activity {//(1)  
  7.     @Override  
  8.     protected void onCreate(Bundle savedInstanceState) {//(2)  
  9.         super.onCreate(savedInstanceState);  
  11.         setContentView(R.layout.activity_main);//(3)  
  12.     }  
  13.     @Override  
  14.     public boolean onCreateOptionsMenu(Menu menu) {//(4)  
  15.         // Inflate the menu; this adds items to the action bar if it is present.  
  16.         getMenuInflater().inflate(, menu);  
  17.         return true;  
  18.     }  
  19. }  

(1) Activity is a java class that creates and default window on the screen where we can place different components such as Button, EditText, TextView, Spinner etc. It is like the Frame of Java AWT.

It provides life cycle methods for activity such as onCreate, onStop, OnResume etc.

(2) The onCreate method is called when Activity class is first created.

(3) The setContentView(R.layout.activity_main) gives information about our layout resource. Here, our layout resources are defined in activity_main.xml file.

Learn More with Madanswer

Related questions

0 votes
asked Jan 14 in Android by RShastri