Create and Run an Android Application
In this article I am going to
explain how to create and run an Android application in Android Emulator. In
order to run an application we have to create an
Android Virtual Device (AVD). An AVD
defines the system image and device settings used by the emulator.
Perform the following steps to
create an AVD:
1)
In Eclipse, select Window
Android SDK and AVD Manager.
2)
Select Virtual Devices in the left panel.
3)
Click
New.
The Create New AVD dialog appears.
4)
Type the name of
the AVD, such as "MyAVD_Device".
5)
Choose a target.
The target is the platform (that is, the version of the Android SDK, such as
2.3.3) you want to run on the emulator.
6)
Click Create AVD.
When you start your AVD, it seems like below:
Create a New Android Project
After creating an AVD move to
the next step and create a new project in Eclipse.
1)
In Eclipse, select File
New
Project.
2)
Select Android Project and click next.
3)
After click on next, you have to enter the project details in the
New Android Project dialog box. Fill
in the project details with the following values:
Project
name: FirstAndroidApp
Build Target: Select a platform version that is equal to or
lower than the target you chose for your AVD.
Application name: FirstAndroidApp
Package
name: com.example.firstApp (or your
own private namespace)
Create
Activity: HelloAndroid
4)
Click Finish.
Your Android project is now ready. It should be visible in the Package Explorer
on the left. Open the HelloAndroid.java file, located inside
FirstAndroidApp
src
com.example.firstApp).
Add some lines of code in order to change the UI (User Interface):
package
com.example.firstApp;
import
android.app.Activity;
import
android.os.Bundle;
import
android.widget.TextView;
public
class HelloAndroid
extends Activity {
/** Called when the activity is first created. */
@Override
public
void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv=new TextView(this);
tv.setTextSize(20);
tv.setText("Welcome in the world of Android");
setContentView(tv);
}
}
Run the Application
Now after creating an application, run an application.
Right click on the project (FirstAndroidApp) which is
shown in the Package Explorer
Select
Run As
Android Application.
Output

After performing the above steps you can easily learn how to create and run and
simple Android application by using Eclipse IDE..
Thanks.