Monday 7 January 2013

How to Write an Android Application

The Android mobile operating system has been gaining popularity and learning how to write Android applications can make you a more marketable programmer. Android is an open-source operating system owned by Google and runs on mobile phones as well as tablet computers. Android applications are written using the Java programming language. One of the best development tools that can get you started is Eclipse. Develop your Android app and then test it using a virtual device.

Step 1

Use Eclipse development tool to develop your Android application. You can download it from eclipse.org/downloads/.

Step 2

Install the Java JDK from oracle.com/technetwork/java/javase/downloads/index.html.

Step 3

Download and install the latest Android SDK Tools from developer.android.com/sdk/index.html.

Step 4

Launch Eclipse and navigate to “Help > Install New Software” and click “Add.” Type “Android” for the name and set the link to "https://dl-ssl.google.com/android/eclipse/."

Step 5

Check both boxes next to “Android DDMS” and “Android Development Tools” and click “Next.” Navigate to the folder where you downloaded the Android SDK and double-click “SDK Setup.exe.” Download the Android 2.1 and Android 2.01 packages and click “Install.”

Step 6

Create a new Android Virtual Device (AVD) to test run your programs by clicking the “Window > Android SDK and AVD Manager.” Click “New” and type a name for your AVD. Select the “Target” as “Android 2.0.1 API Level 6” and leave the other settings as default. Click “Create AVD.”

Step 7

Launch Eclipse and configure it by clicking “Window > Preferences” and expand “Android” from the left pane the “Preferences” dialog window. Browse for the location of the Android SDK, and click “Apply.”

Step 8

Create a new project by clicking “File > New > Other” and expand “Android.” Click “Android Project” and input a name for your project. Check the box next to “Android 2.0.1,” input an Application name, Package name, and click “Finish.”

Step 9

Press “Ctrl” and “A” to select the auto-generated code. Copy and paste the following code to create your Android application: package com.android.helloandroid; 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.setText(“My Android application!"); setContentView(tv); } }

Step 10

Click the “Play” button to run the program and display a message through the virtual device.

No comments:

Post a Comment