My First Android Program

It’s pretty exciting to write about developing first program in Android. In our first program, we are going to have an image and label on the Window.

Its a simple traditional ‘Hello World’ program.

Let us begin with it by opening new android project in eclipse.

Quick Links

Project Structure

Launch eclipse, open new android project in either of the two ways:

File >> New >> Others >> Android >> Android Project

File >> New >> Android Project

Click next and provide project name which is going to be your Activity Class name, so make sure your project name must suite your functionality of the application.

After providing project name, click next and choose Android target device version. You have to choose your device’s installed Android version.

Click next and provide package name. Package name must follow naming convention since a particular device will have multiple packages which should not be ambiguous at run time. So follow below mentioned naming scheme:

com.myapp.”Name of your app”



All done, you have successfully created ‘New’ android project. Let’s modify the default layout and add controls to the application we just created to bring an image – Android logo and label – Hello Android at the center of the device’s window as we discussed earlier.

Code Listings

To begin with layout modification, we need to add an image – Android logo to the resources folder and add text ‘Hello Android’ in strings.xml.

Expand Project folder >> res >> drawable-hdpi >> Place/Paste Android logo image

Expand values folder >> Open strings.xml >> Look for String ‘hello’ >> Add text ‘Hello Android’ to ‘hello’ string element

Open main.xml under res/layout folder and replace the xml with the below xml which has one image and one label aligned centrally.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:orientation="vertical" >

android:src="@drawable/android_logo" />

android:text="@string/hello" />


Open ‘Graphical layout’ of the main.xml, you could see the design of our application. Graphical layout allows you to design application UI just by doing simple drag and drop the controls.

Make sure ‘Build Automatically’ option under Project menu is selected so that project will be built automatically every time after you did change.


That’s it, we need to run the program and check the output.

Right click on the Project >> Run as >> Android Application >> Select emulator [configured at the time SDK installation] or Your Android device


Google installs ‘Emulator’ along with the SDK installation. It’s upto you whether you want to run the application in Emulator or in your android device. I would prefer to run my apps on my device since most of the services like GPS, Google inbuilt services, bluetooth etc are not supported in Emulator but still application will run without any issues in Emulator if your app doesn’t involve any of the aforementioned services.

You must enable ‘USB debugging’ in your mobile settings so that it will be acting as target device when connected to your PC. And its simple to run your app in Mobile device.
Here is our most awaited output:

Download Source Code

Entire project is zipped and is available for download. Unzip the downloaded project and to import the project into eclipse, launch eclipse >> File >> Import.. >> Choose downloaded project (How to import android project in eclipse). If you just want to run the application in your mobile and see the output but don’t want to hit your head with source code, download application(apk) file and install it in your mobile device.

Download Source Code Download Application(apk)

*apk in Android  is the installation file simliar to exe in windows.

Keep me posted with your valuable feedback. 🙂
Thanks for reading the post!!
Do share with your friends if you want to let others know about this content!!


Related Articles

Author: Udhay

Share This Post On
468 ad
Join now to get more access to our Android Tutorials

Join now to get more access to our Android Tutorials

Once you Join, you will receive Mail containing latest Android Tutorials once a month !!

I promise I wont spam you !!

You have Successfully Subscribed!

Pin It on Pinterest