articles

Home / DeveloperSection / Articles / Create and Run an Android Application

Create and Run an Android Application

Chris Anderson6595 14-Oct-2011

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:
   In Eclipse, select Window à Android SDK and AVD Manager.
  •   Select Virtual Devices in the left panel.
  •   Click New.
  • The Create New AVD dialog appears.
  •  Type the name of the AVD, such as "MyAVD_Device".
  •   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.
  •  Click Create AVD.
  • When you start your AVD, it seems like below: 

 

Create and Run an Android Application

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.

 

Create and Run an Android Application

Your Android project is now ready. It should be visible in the Package Explorer on the left. Open the HelloAndroid.java file, located insideFirstAndroidAppà 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

Create and Run an Android Application

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

Thanks.


Updated 07-Sep-2019
hi I am software developer at mindstick software pvt. ltd.

Leave Comment

Comments

Liked By