Android Development Tutorial
Android Apps Development Tutorial is a detailed training on developing android applications from ideas to apps store. You are going to start your android development journey through this android development tutorial by work out the smart examples which absolutely very simple yet effective examples you can even download.Android Development Tutorial — Building blocks of Android
Android platform structed in a way that makes phones more crash-resistant.
Activities
Activity is the building block of the user interface. To be straight into the point, a activity is like the page in a Web app. Android supports a lot of activities. When ever a user cliks submit/login button you can bring up new activities and pressing the back button to back up, just as like as we do in a web browser.
Services
Activities are short-lived and it can be stopped or shutdown at any time.
Services, on the other hand, are designed to keep runnig, independent of any activity. One simple example for service might be checking updates to a twitter/email account.
Intents
Intents are system messages.
- Used to notify various events like incoming data, hardware state changes…
create our own intent to launch other activities. - We are going to use Eclipse IDE through out this Android Tutorial for Beginners series. It is simple to use yet very effective ide out there for android platform.
Android Development Tutorial Eclipse Installation for Android
If you don’t have eclipse installed in your system then continue reading this post, otherwise you can skip the below steps and
Eclipse Download
Ok, now you have eclipse ide. Unzip the downloaded package file and run eclipse.exe
You can download any of the following versions.[/box]Install
The Google APIs add-on includes

First Android Program
- Start Eclipse IDE in which the Android platform is installed.
- Lets start our First Android Program by creating a new Android Project.
- You can create an android project by one of the following ways.
- click the Create Android Project Icon.
- File-New-Android Project.
- Right the Package Explorer Area and go New-Android Project.
In the New Android Project Window, we need tell eclipse a few things about our project
- Project Name : Name of the project
- And how to create your project
- Location where you want to save
Now lets click Next to move to the window where we can select the target SDK.
- In Select Build Target Window we can choose the target SDK.
- If you want to develop an application that need to support most of the android devices out there in the market.
- Then you should select Android 2.1
- If your application is going to make use of Maps then select appropriate Google APIs version.
- In this First Android Program, I am going to use Android4.0.3, just to see how the new version looks like.
Click Next to bring up the next window where we are going to configure our android project.
Application Name
Package Name
Android likes to keep things structured and nicely ordered. We need to give the name of the package where our project files, icon images are going to be stored.And the name you are giving here should be unique.
Make sure Create Activity is checked
and the value here is the name of the activity thats going to be created by android for us.Don’t change anything for now, we can take a deep look at this later.
Minimum SDK
This field is used to specify a minimum platform version for your application
I am going to leave this field as it is for now.
- Click Finish.
- Now you can see the HelloWorld project is created.

- It will boot up the Android Emulator.
- If the Emulator is running for the first time then it will take some time to load.
Take your time and play around with Android.



Now it is time to take a look at our project folder.
- In src folder you can find our package, inside the package you can see HelloWorldActivity which we selected at time of project creation. If we didn’t choose that option, now we wouldn’t have this activity.
- Next see the gen folder. The files in this directory is generated by the Android platform. So don’t change anything in that.
- Then come to the res folder here we have our resource files laied out.
- The Icon of our application is in this drwable folder only.
- In layout folder by default you will have only one xml file called main.xml
- The layout xml file is like a screen of the application.

As you start developing your application you will use more layout xml files. The layout xml file is like a web page where every page is unique and has its own set of components like buttons, text box, images …
- So for example in a user login system,
- login form is a xml file – login.xml
- It has name and password fields.
- Based on the user input it will open one of the two different layout.
- user.xml – has user information
- error.xml – has error message
Inside values directory we have strings.xml, This is where we are going to define all of our String variables.
id and value. id should be a unique one.
AndroidManifest.xml is a file which has informations about how this application should run in a device, which layout it should launch as MAIN.
What are the activities the application has, and which image it should use as icon and we can take a look closer at this in coming days.
But how is it displaying “Hello World, HelloWorldActivity!”
You have the answer in the following image.

Open main.xml from layout folder. And change the view option from Graphical Layout to coding window.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout>
- The first line is the xml version.
- LinearLayout – is the default layout. But there are number of layouts available. We have to choose a layout in a way that can be appropirate to our application. If you are creating a photo gallary viewer application then you need to use grid view like.
- TextView – is like a label, we need to specify width, and height of the label.
- And carefully look at the next line
android:text="@string/hello"
- Go inside the values folder we have strings.xml, and open it.
- Choose strings.xml at bottom, it will show the coding window, here you can find the following code.
<string name="hello">Hello World, HelloWorldActivity!</string>
name – name of the variable. Should be given inside the double quotes.
The value of the variable “hello” needs to be given inside the tags.
<string name="hello">Hello World, HelloWorldActivity!</string>
And finally don’t forget to put closing tag
Now I am going to create a new string variable called “welcome”.
For this I need to write the following code in strings.xml
<string name="welcome">Welcome to First Android Program</string>
Then in
Now save the changes and run the project as Android Project.
Here Android plays a smart trick to keep everything nice and clean. Whenever we create anything like string variable, color variable, a new layout, image or icon … It will store its information inside a common Resource file called R.java
Finally we came to know that the name of the xml file doesn’t do anything we can even give myStrings.xml
Now the time comes to take a peek into R.java
open R.java inside gen- your package

- android:textSize Size of the text in points ( pt ) – “10pt”
- android:textStyle Style for the text. (bold, italic, bolditalic)
- android:typeface Typeface for the text.(normal, sans, serif, monospace)
- android:autoText If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors.
- android:capitalize If set, specifies that this TextView has a textual input method and should automatically capitalize what the user types.
- android:gravity Specifies how to align the text by the view’s x- and/or y-axis when the text is smaller than the view.
- android:marqueeRepeatLimit The number of times to repeat the marquee animation.
- android:textColor Text color.
- android:textColorHighlight Color of the text selection highlight.
- android:textColorLink Text color for links.
Three ways of creating a String
- So far we have create string using coding window
<string name="Name">Name</string>
In main.xml , just enter the android:text value inside TextView, now the android will give warning to us that the string has not created. Now select the string and goto Refactor from top menu and perform Android=>Extract Android String.
Now the Extract Android String window will appear, in that you need to give the String value that you want in the String text field, and the variable id/name in the Replace by R.String text field.
Finally select the Resource file where you want to include the String, in this case strings.xml
Then press ok to create the string variable. Now the warning has gone in the main.xml and instead of “hai” you will see “@string/hai”.
Now its time to place our string at the center of the screen, for that we need to tweek main.xml
Insert the following code inside Linear Layout
android:gravity="center"
And in the TextView we need to change the
android:layout_width="wrap_content" android:layout_height="wrap_content"
- wrap_content – means it will take the size of the content.
layout_width=”wrap_content” – then the width becomes the length of the text.
layout_height=”wrap_content” – then the height becomes the height of the text.
Lets change the color of the Text and Background.
Sofar we have know how to create string, but how can we insert color property?
android:textColor="#ff0000"
#ff0000 is the hexa decimal value for the color red.
- To change the background property of the layout, insert the following code inside LinearLayout.
android:background="#00ff00"
- Add the following code inside the resource tag of strings.xml
<color name="my_red">#ff0000</color> <color name="green">#00ff00</color>
- Then in main.xml you can use the color name instead of hexa-decimal.

android:textcolor="@color/my_red"
- If you don’t want to mess up strings.xml with color values then create a new xml file in values folder and give any descriptive name to the xml file.

- Right click values folder then goto New=>File
- Choose the parent folder that is values folder then,
- Give the name of xml file like colors.xml then click Finish.

It will create colors.xml file copy the following code to colors.xml from strings.xml file.
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="green">#00ff00 <color name="red">#ff0000 </resources>
Then cut and paste the color code from strings.xml to colors.xml.
<color name="red">#ff0000</color> <color name="green">#00ff00</color>
Save Changes in both xml files.

Lets take a look at HelloWorldActivity.java in src=>package.
- HelloWorldActivity extends Activity
- onCreate() is the method called when the activity is first created
- setContentView(R.layout.main) –
Here we have set up the main layout as our default layout. That is when the application launch at the time main layout will be appear.
- R – resource R.java
- layout – Layout Class
- main – variable in the layout class.
So in our java code, if we want to specify our android elements we need to refer R.
Finally we are going to give attention to AndroidManifest.xml
android:minSdkVersion=”15″
Inside
android:label=”@string/app_name”
this is the application name.
If you want to change your application name then change it to any desire name you want.
activity
is used to add activity information to the Manifest file.
Whenever we create an activity we need to register the activity by giving name of the activity.
<activity android:name=".HelloWorldActivity" android:label="@string/app_name"/>
If you want to change the app name when this activity is loaded then specify the text as
android:label="@string/desire_name"
Intentfilter is used to specify the activity which should be used as the launcher of the application.
Now we are going to change the Icon of our Application.
- To change the icon of your application,
- place your icon image in the project folder called res=>drawable
- Now in Eclipse refresh your project folder.
- Finally you need to change the icon name in your Manifest file.
android:icon="@drawable/logo"
You have set up everything perfectly, now its time to run our program, so save all changes and run as Android Project.You will see the following screen shot.
And also we have peek on the Activity, and Manifest file.
Complete Code
main.xml<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center" android:background="#555555" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hai" android:textColor="@color/red" android:textSize="10pt" android:textStyle="bold" android:typeface="serif" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/welcome" android:textSize="10pt" android:typeface="serif" android:textStyle="bold" android:textColor="@color/green"/> </LinearLayout>strings.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, HelloWorldActivity! <string name="app_name">HelloWorld <string name="welcome">Welcome to VimalTuts <string name="hai">Hai </resources>colors.xml
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="green">#00ff00 <color name="red">#ff0000 </resources>AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.vimaltuts.android.helloworld" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" /> <application android:icon="@drawable/logo" android:label="@string/app_name" > <activity android:name=".HelloWorldActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>HelloWorldActivity
package com.vimaltuts.android.helloworld;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Lets continue our Android development. This android development tutorial is just like get into the car but you need to drive a long way to reach your destination. Keep reading all the tutorials in the android development tutorial section. Google+
VimalTuts Code Junction 

























