Write your own Android applications: Getting Started

Guest Posts Omar Shehab

This article will show you how to install and run your first Android application preparing for next steps.

Requirements: Android Developer Tools with Eclipse:


  1. Android software development kit (SDK)

    • You can download the SDK from Download

    • You will get a zip file

    • Extract the zip file and execute the file called eclipse.exe



  2. Java Development Kit (JDK).


  3. Java integrated development environment (IDE).

    • In Eclipse IDE click on Help – Install New Software... – Add

    • Write the name such as “ADT”.

    • Write the https://dl-ssl.google.com/android/eclipse/ in the location bar.

    • Tick the Developer Tool check box and click Next.

    • Click Finish and restart the ADT to take the effect.

    • Click Android SDK Manager in the tool bar.

    • Select the API you need to develop and click install button, the following is a list of all the API with the corresponding versions and codename:




[caption id="" align="aligncenter" width="400"] Android API Levels[/caption]

The following snapshot exhibits the Android SDK manager window on Eclipse:

[caption id="" align="aligncenter" width="426"] SDK Manager[/caption]

Note: To start developing you need to download at least one SDK platform release by running SDK Manager.exe on windows OS and running “android” executable in the tool subfolder of the starter package download on Mac OS and Linux.

Java Spring Framework:

Implementation: Create Simple Application

  1. File – Create – Project.

  2. Select Android Application Project from Android folder.

  3. Write the application name such as “Android First Code”.

  4. The project name and package name will fill their text boxes automatically.

  5. Keep click Next till reach the Finish button.


The following code will generate automatically.

package com.example.androidfirstcode;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}


Servlets and JSPs:

Run on the Emulator:


  1. On eclipse click Android Virtual Device Manager from the toolbar.

  2. Click New button.

  3. Write your AVD name such as “myFirstApp”.

  4. Select the device you design your application for. Such as 3.7” WVGA (480 x 800: hdpi).

  5. Select the API level which is the version of your Android.

  6. Select ARM architecture which is majority of mobile device in the market.

  7. Change the size of RAM in memory option to be 512MB.

  8. Click OK button.

  9. Select the AVD you have been created and click start button.

  10. Click launch button.

  11. It will take long time to launch the emulator.

  12. Also you are able to click run button from the toolbar.


The output will be:

[caption id="" align="aligncenter" width="350"] Android Emulator[/caption]

If you go to the activitymain.xml tab on eclipse window you will find the following xml code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout
width="matchparent"
android:layout
height="matchparent"
android:paddingBottom="@dimen/activity
verticalmargin"
android:paddingLeft="@dimen/activity
horizontalmargin"
android:paddingRight="@dimen/activity
horizontalmargin"
android:paddingTop="@dimen/activity
verticalmargin"
tools:context=".MainActivity" >

<TextView
android:layout
width="wrapcontent"
android:layout
height="wrapcontent"
android:text="@string/hello
world"/>

</RelativeLayout>

Textview contains the “hello_world”.

Java Swing:

Thanks.