Android simple application

Hello again,

After having Android SDK installed, as described in a previous post, now let’s create a simple application. I want to focus on Android system rather than the language. Either way, the language shouldn’t be a problem. The scenario would be like have 3-4 screens and have a couple of buttons to move around these screens. Nothing fancy.

Prepare IDE

The typical IDE for Android is Eclipse classic with the Android Development Toolkit (ADT). Since I prefer Pulse to manage my Eclipse profiles, you might need to see the original guide to Eclipse+ADT installation here. Anyway, I created a new profile based on Eclipse Classic 3.7 Indigo, added the Android Development Toolkit as well as Subversive and Subclipse.

Go to Preferences / Android and enter the SDK location. In my case this is:

/Users/goulas/tmp/android/android-sdk-mac_x86

Hitting Apply there will fill up the list of SDK Targets.

Create the new Application

In Eclipse, go to File/New and select Project / Android / Android Project. Then enter a project name and select a Build Target (Android 2.1 -update 1 for me, since I haven’t updated my Samsung Galaxy S GT-I9000).

My options for the sample project:

  • Project name: HelloAndroid
  • Target: Android 2.1 -update 1
  • package: goulas.helloAndroid
  • Create Activity: HelloAndroidActivity

Don’t press next, it will just clear the form. Press Finish.

Major files

Have a look at a number of major files.

  • Manifest AndroidManifest.xml Glues everything together
  • Layout res/layout/main.xml Layout of the screen
  • Strings res/values/strings.xml All text resources for the application

Also, check the HelloAndroidActivity java file in src/goulas/helloAndroid/HelloAndroidActivity.java

package goulas.helloAndroid;

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

public class HelloAndroidActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

Running the application

Although not having done anything, the application can run on the android emulator. Run the application as usually in Eclipse, but be sure to select Run as Android Application.

So far, so good, we managed to get to the point to run a Hello World application from Eclipse instead from the Android SDK, which we did in the previous post. I believe this is the point where the fun begins, until now everything is boring and straightforward.

Advertisements

Posted on August 9, 2011, in Android and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: