Android !

What’s up!!!

Did you know what is Android?

If you are a beginner you can start here, if you have notions about programming and android you check here out.

I would say Android is not only a Operating System for mobile devices, but with many frameworks and applications involved in it, we could call it a software stack. This Stack is composed by Frameworks, applications (e.g: Browser, Caller, games, etc),  Virtual Machine (The Dalvik),  mobile devices features (Camera, 3G, EDGE, Touch Screen, GSM or CDMA TEchnology, bluetooth, Wifi, GPS, accelerometer, etc) and in addition a development kit for developers. The SDK for developing and debugging . And the great point in all of this, it is free. An OPEN DEVELOPMENT PLATFORM.

Many companies are adhering Android in their phones like Motorola, HTC, Sony Ericsson, Samsung, etc…

IF you want to start in android world you will need 4 basic things. Eclipse IDE, where you are going to develop android apps, your own apps. Sun’s Java Development Kit, The JDK The Android Software Developer’s Kit (SDK) and the Android developer tool (ADT), the plugin for eclipse (this last one you can download and install by eclipse).

First, Download All those 3 software. Then Install the JDK (whether you do not have it installed).

Download Eclipse and the Android SDK.  If you running on Windows both are going to be zip files. Extract them separated, each one in its folder for example:  C:\eclipse and C:\android. It is just up to you.

One step for windows, you have to edit your Enviromnet Variables and add the C:\android\tools to it.  How? simple.

Right click on My Computer and go to properties. There find the System Properties and then Advanced System settings (or in WinXP just the tab Advanced). The in the second box you look for a variable called path. Click on it and edit it. In the end add the address of android tools. If you have followed my example would be C:\android\tools . This is necessary to make it easier to launch Android tools.

Ok. Time to start Eclipse. Just open it.

Go to Help -> Install New Software

Now click in Add, and then add the android address :



In the Locations you can type: https://dl-ssl.google.com/android/eclipse . Click OK.

The Developer tools will appear. check check it and click on NEXT.

You have to accept the terms of the license and then click Finish.

Restart eclipse.


If you do not get a warning about the plugins are not installed (if yes just install all) go to the Window -> Preferences and then Android as the pic bellow shows

 

 

Here you have to add the Android path to eclipse recognize the android API.

When you do that you already can start a New Android Project. But when I do a application I should see a cellphone screen and see my application running in it, right? yeah. So, is it already set up? Let’s check if everything is ok!


Go to Window -> Android SDK and AVD Manager ; Here you will see the packges and the Virtual Device (what would be the cellphone). First Check the packges. If they are not installed, check them and just click install. After that Go back to the Virtual Devices to create a new AVD (Android Virtual Device).  Click New. Then type the name of the AVD, I suggest ” my_avd”. You have to choose a target. The target is the API that you are going to use in your AVD. We could see as Android versions.

Select the version that you want and click “Create AVD”.

Ok. After you Configure the Android development environment is time to start.

Go to File -> New -> Project ; Click in Android Project

Look the image bellow:

First, you have to name your project. We could start with a HelloWorld.

Second, choose the Android API in the list Build Target. There, you will see many Android “versions” and choose any you want to start your project. I recommend you choose the same as you have chose when you configured your AVD.

xD

Then you have 4 fields in blank.

The first one is the application Name. It has to have a name. HelloWolrd.

The name, you will see in the Android menu. The name of your application.

The Second one, the package.  Your application have to be in a package. And the name of this one has to have at least two identifiers. E.G:  android.helloworld or firstapp.android. It is just up to you what name it.

The last, that you need to fill out is the Activity.

—–  Brief explanation  —–

The Android Application is composed by four components. There components are defined by Android architecture.

Activities, Services, Broadcast and Intent Receivers and Content Providers. This post I will talk about the Activities. In the future I will talk about the others. But if you want to read about them, just check this link.

When you create an Android application, your application always have to has an activity. Even a “HelloWorld!”  has one. Activities are that chunk of code running in time. For example, Screens; Each activity shows one screen to the user. If one Activity is not being used, or not actively running the operating system can kills it, so it can conserve more memory.

—————————

So, the name of the activity is HelloWorldActivity .

Then click on Finish.

Ok. Now you just started an Android Project. You have your first application ready to run.

Before you run it. Let’s take a look at what we have.

In the src (the source) folder, we have the package that you name it as you wanted.

I just named blog.helloworld . And bellow this directory we the gen folder. It is where you will find the R.java .That is all resources from res directory in Java.

Then we can see the Android library. If you click on it, you will all jars that composes the android library that you have chose before during the project creation.

As a resource, you could have any images, bitmaps, or whatever you need for your application.

The layout tells android how dispose items, things on the screen when applications runs. You can check it out, and you will see a XML file.

Values are outside the source. You can use them anytime. What is this? Values are constants, strings, etc..

At last, we have the manifest. The manifest a XML file too. This file defines all components in your application and tell Android about all components that exists in your application.  So, it learn and know about all components in your application before build it.

Now, go to the strings.xml file. And just edit the line that you see HelloWorld. This is going to be the output. You can see in the next line. The name of your application.

Right click on the project and then click on Run As -> Android Application

Pan, Pan Pan Paaaannn!!!

Now the your application is going to run in the emulator, the AVD that you have created.

The Java is going to start too.

You will see that the emulator is like a virtual machine.  So you will see a cellphone on your screen. Just go the menu and find your application and click on it. It will start to running and congrats, you made your first Android App!!

Advertisements

About renatopuccini
Android Developer. Passion for what I do!

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: