Hello Android (Android 1.5 or 1.6)

13 12 2009

In this post we will learn how to make a simple Hello Android with Android 1.5 or 1.6. Open your Eclipse and let’s go:

#STEP 1 – Create a new Project

File -> New -> Android Project


_

After that you will see something like this:

_

_
Ok, is time to fill the fields:

PROJECT NAME: Type a nice name for your project (it can be easily changed later)

CONTENTS: “Create new project in workspace”. It’s our first project.

BUILD TARGET: Select Android 1.5 or Android 1.6. Don’t worry about Google APIs option for now.

PROPERTIES:

  • APPLICATION NAME: The name of your application. This name will be shown to the user.
  • PACKAGE NAME: Type the root package of your project. E.g.: com.you.helloAndroid.
  • CREATE ACTIVITY: Type the name of your main activity. (Don’t know what Activity is yet? Don’t worry. I will explain it the next posts. But if you can’t wait for that, click HERE.
  • MIN SDK VERSION: Type 3 if you choose Android 1.5 or type 4 if you choose Android 1.6. With this identifier you can define SDK target of your application. E.g.: if you type 3 for MIN SDK VERSION you’re assuming that your application will run only on devices updated with Android 1.5 or later.

Well, click FINISH.

#STEP 2 – Making the Hello Android happen (so so)

After Step 1 our Hello World is almost complete! “Really? No more code is needed?” Yes, no more code is needed. You must for now change the default “Hello world” message to something you like.

In Package Explorer (Eclipse) open the strings.xml file of your project (res/values/strings.xml):

_

_

You will see something like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
 <string name="hello">Hello World, MainActivity!</string>
 <string name="app_name">FirstApplication</string>
</resources>

Change the text "Hello World, MainActivity" for something you want.


#STEP 3 - Executing the Hello World

Create an AVD (Android Virtual Device) before to execute your project. AVDs were available since Android 1.5. The advantage of them is to create many devices with different configuration and test your project on them.
Well, click on this almost hide button on Eclipse (near Save button):


In the next screen you will see something like this (maybe this screen is different on your Eclipse, but the functionalities are the same):

Click in the NEW... button and follow the fields (ignore SD Card field for now):

Click CREATE AVD....

Now go to RUN CONFIGURATIONS... option for creating a New Configuration to your project:


Create a New Configuration named "HelloAndroidConfiguration", select your project and then select your project's main Activity (we created only one):

Select the AVD you created previously:

Click APPLY and then RUN! Now wait for the loooong Emulator loading... when the Android desktop is shown, unlock the screen by pressing MENU and wait your application be opened:


Yeah! It works!!! =)

Well, this is enough for now. Congratulations for your next Android program! Keep going on!

About these ads

Actions

Information

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s




Follow

Get every new post delivered to your Inbox.

%d bloggers like this: