Step 02: Hello World App (Java)

    1. Connect your cell phone (HTC Desire S) to your computer using a USB cable.
    2. On your cell phone go to Setting>Application>Development and enable USB debugging.
    3. Start Eclipse by double clicking its icon on your desktop.
    4. From the "Window" menu, select "Open Perspective > Other..."
    5. Select DDMS and click OK.
    6. Check if your cellphone is listed under the "Devices" view and if the logs are being shown under the "LogCat" view. (In Eclipse, various tabbed panes are called "views")
    7. Go back to the "Java" perspective by clicking on the "Java" button on the top right corner within Eclipse.
    8. Select "New > Project..." from "File" menu.
    9. Select "Android Project" listed under "Android" folder and click "Next >".
    10. Enter details as follows:
      • Project Name: 01HelloWorld
      • Check "Android 2.3.3" as the Build Target
      • Application Name: HelloWorld
      • Package Name: com.lithiumhead.android.HelloWorld
      • Check "Create Activity" and enter the name as: HelloWorldActivity
      • Leave everything else on default
    11. Click "Finish". A new package will appear under the "Package Explorer".
    12. Navigate to "HelloWorldActivity.java" listed under "01HelloWorld > src > com.lithiumhead.android.HelloWorld" in the Package Explorer and double click to open it's source code.
    13. Replace the contents of "HelloWorldActivity.java" with:
      1. package com.lithiumhead.android.HelloWorld;
      2. import android.app.Activity;
      3. import android.os.Bundle;
      4. import android.widget.TextView;
      5. public class HelloWorldActivity extends Activity {
      6. /** Called when the activity is first created. */
      7. @Override
      8. public void onCreate(Bundle savedInstanceState) {
      9. super.onCreate(savedInstanceState);
      10. TextView tv = new TextView(this);
      11. tv.setText("Hello World!!");
      12. setContentView(tv);
      13. }
      14. }
    14. Save HelloWorldActivity.java by pressing "Ctrl+S".
    15. Wait for the package to be built automatically. Progress indicator will appear on the bottom right within Eclipse along side the message "Building Workspace".
    16. Right click "01HelloWorld" under "Package Explorer" and select "Run As > 1 Android Application".
    17. Unlock your cellphone by clicking the "Power" button on the top side and then sliding your finger over the screen.
    18. After the screen unlocks, you will see the HelloWorld App running on you phone.
    19. You can observe the installation messages under the "Console" view within Eclipse.
    20. To uninstall the "HelloWorld" App, on you PC start cmd.exe and issue the command "adb uninstall com.lithiumhead.android.HelloWorld".

References: