Custom Search

Monday, June 22, 2009

Understanding the sample hello world android app

Development Environment

The Android SDK supports several different development environments. I have experimented using Eclipse, so I will be talking about it in this blog. Also, it is very well integrated with the android SDK, and it’s free :-).




To start developing with Eclipse you will require these tools:




Sun’s Java Development Kit (JDK)


The Android SDK


Eclipse (I have been using Eclipse Ganymade)


A special Eclipse plug in: the Android Developer Tool (ADT)



Starting a New Android Application: HelloWorld
Several components are needed to build an Android application. Fortunately, the Eclipse IDE with the Android plug-in automates a lot of the work needed to create and maintain these components. We will start by using the IDE to create a project for our application. Start up Eclipse and select “File -> New -> Project…” from the menu bar (be sure to select “Project…,” not “Java Project”).

Select “Android Project” and click “Next” to get the “New Android Project” dialog box.
We’ll use “HelloWorld” as the name for both the Project and the Application. You don’t need to change the button or checkbox selections, and we’ll use the package name com.myapp.helloworld as shown.

Every Android application has to have at least one Activity (an executable that usually has a user interface), so let’s say we’re going to include an Activity called HelloWorldActivity, Click “Finish,” and the Android Development Kit does a number of things for you, to make your life easier as a developer. In the Package Explorer window you will see some of the files and directories that the ADK created.

The ADK created a HelloWorld directory in the default Eclipse workspace for your project. It also created subdirectories for your source files (.src), references to the Android Library, assets, resources (.res), and a manifest file (AndoidManifest.xml). In each of the subdirectories it created another level of subdirectories as appropriate. Let’s take a quick look at them:

Sources (under .src)

Contains a directory structure that corresponds to the package name you gave for your application: in this case, com.android.helloworld.

Contains a Java template for the Activity you indicated was in the application (HelloWorldActivity) and a directory of resource references (R.java).


Android Library
This is where your application will go for Android library references.


assets
Files you want to bundle with your application. We won’t have any for HelloWorld.

Resources (under .res)
Drawable resources are any images, bitmaps, etc. that you need for your application. For HelloWorld, the ADK has supplied us with the default Android icon, and that’s all we’ll need.

Layout resources tell Android how to arrange items on the screen when the application runs. These resources are XML files that give you quite a bit of freedom in laying out the screen for different purposes. For HelloWorld, we’ll just use the defaults generated by the ADK

Values are constants, strings, etc. available for use by your application. Keeping them outside the sources makes it easier to customize the application, such as adapting it for different languages.

Manifest (AndroidManifest.xml)
This is an XML file that tells the Android build system what it needs to know to build and package your application so it can be installed on an Android phone or the emulator. This file has its own specialized editor, which we’ll describe as we get to more complicated applications.
Double Click on HelloWorldActivity.java

Looking quickly at the template code that the ADK has provided for us, we can note several things:

The ADK has included the package reference we asked for, which is consistent with the directory structure it created.It has also created a (collapsed) set of imports for the library references it knows we need.It created a class definition for the Activity we said we wanted (HelloWorldActivity) including a method called OnCreate.

For the moment, don’t worry about the parameter passed into OnCreate. The Bundle is a way of passing data between activities and storing data between instantiations of the same Activity. We won’t need to use this for HelloWorld.

One special line of code has been included in OnCreate:setContentView (R.layout.main);
Remember that Android uses layouts to define screen layouts on the target, and that main.xml was the name of the default layout file that the ADK created for us under .res/layout. The R.java file is generated automatically and contains java references for each of the resources under .res. You will never need to edit the R.java file by hand— the ADK takes care of it as you add, change or delete resources.

Wednesday, April 1, 2009

Android Racing ahead





















HP is evaluating Google's open-source Android operating system for use in some its PCs and mobile devices. A spokesperson for HP said that the company is "studying the Android operating system". However, HP stressed that it remains open to considering various operating system options.



Asus, meanwhile, has already announced plans to port Android to its netbook range.





















Commenting on the reports, Google said that it designed Android to be open and scalable for precisely this type of application."Android is a free open-source mobile platform, so anyone can take the Android platform and add code or download it to create a mobile device without restrictions," said a Google spokesman.

LG Electronics has already announced its plans of going to equip two new smartphones with Android, following the footsteps of Samsung and Motorola.

Thursday, February 26, 2009

offline gmail

Google demonstrated how gmail can be accessed offline along with its features such as search etc enabled on an iphone. This doesnt require any iphone specific software to be installed. Instead it makes use of HTML to enable this features. This is how it has challenged Apple allowing iphone uses to make use of Google's features at no extra cost. If the same was enabled though a software then apple would have taken a roality for making the application available on its apple store, but this wont be the case.

However, this has not been released in the open market. Anyway, we can expect it to hit the market very soon. Google demonstated this feature recently on iphone and Android G1