[Android] Android Hello World Example

Source: Internet
Author: User
Tags android sdk manager

In this tutorial, we show you how to create a simple "Hello World" Android project in Eclipse IDE + ADT Plugi n, and run it with Android Virtual Device (AVD). The Eclipse ADT plugin provided easy Android project creation and management, components drag and drop, auto-complete and Many useful features to speed up your Android development cycles.

Summary steps to develop an Android application:

    1. Install Android SDK
    2. Install ADT Eclipse Plugin
    3. Create an Android Virtual Device (AVD)
    4. Create Android Project with Eclipse (Wizard)
    5. Code it ...
    6. Start it in Android Virtual Device (AVD)

Tools used in this tutorial:

    1. JDK 1.6
    2. Eclipse IDE 3.7, Indigo
    3. Android SDK
1. Install Android SDK

Visit this Android SDK page, choose which platform and install it.

In the Android SDK installed folder, run "Android SDK Manager", choose what the Android version you want to develop.

2. Install ADT Eclipse Plugin

To integrate the Android SDK with the Eclipse IDE, you need to install Eclipse ADT plugin. Refer to this official guide– "Installing the ADT Plugin".

In the Eclipse IDE, select "Help", Install New software ... ", and put below URL:

https://dl-ssl.google.com/android/eclipse/
Note
In my case, above ADT plugin are taking years to download and no idea why. If you is facing the similar problem, just download and install the ADT plugin manually, refer to this ADT plugin trouble Shooting guide.3. Create an Android Virtual Device (AVD)

In eclipse, you can access the 'Android Virtual Device (AVD)' in Eclipse toolbar. Click "New" to create a AVD.

Later, Eclipse would deploy the application into this AVD.

4. Create Android Project

In Eclipse, select "File--New project ....", "Android project", and input your application detail. Eclipse would create all the necessary Android project files and configuration.

5. Hello World

Locate the generated activity file, and modify a bit to output a string "Hello world".

File:HelloWorldActivity.java

Package Com.mkyong.android;import Android.app.activity;import Android.os.bundle;import Android.widget.TextView; public class Helloworldactivity extends activity {    /** called when the activity is first created. */    @Override 
   
    public void OnCreate (Bundle savedinstancestate) {        super.oncreate (savedinstancestate);        TextView Text = new TextView (this);        Text.settext ("Hello World, Android-mkyong.com");        Setcontentview (text);}    }
   
6. Demo

Run it as "Android application", see output.

Press "Home" button (on right hand side), and you'll noticed that "HelloWorld" application are deployed successfully on T He Android virtual device.

Note
This tutorial was more than example driven, not much explanation. For detail and complete explanation, please refer to the official Android developer Hello World Tutorial. Firewall ...
In My computer, the COMODO firewall is installed and blocked the deploying process, caused the connection between Eclipse ADT and AVD are blocked and failed to deploy. Just Make sure your firewall are configured properly, or Just turn it off for Android development:) Debug Android application on real device
Sometime, " Android Virtual DeviceEnough to test some real phone functionalities, such as LED light, sensor and etc. Then you should refer to the "to" debug Android application on real device. Download Source codedownload it–android-helloworld.zip (KB) References
      1. Android Developers
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.