Android Step by Step...

Android is the most exiting open platform which covers operating system, middleware and powerful applications for all types of mobile devices.


This Android platform is the outcome of different top technology leading companies like Google, T-Mobile, Intel, HTC and 30 other companies under the Open Handset Alliance (OHA).

The main intension is to have a new Operating System for hand held devices in which new colorful rich mobile application and services can be developed for the end users.

Configuring your eclipse for android in WindowsXP or Vista:
What we need before we proceed?
  • Java 5 or 6
  • Eclipse 3.3 (Europa), 3.4 (Ganymede)
  • Then Download the SDK for android and extract in any drive (e.g. in C:\ )
  • Getting ready with eclipse by intalling android plugin.
For Eclipse 3.4 (Ganymede):
  1. Start Eclipse, then select Help > Software Updates > Find and Install....
  2. In the dialog that appears, select Search for new features to install and click Next.
  3. Click New Remote Site.
  4. In the resulting dialog box, enter a name for the remote site (e.g. Android Plugin) and enter this as https://dl-ssl.google.com/android/eclipse/ or http://dl-ssl.google.com/android/eclipse/
  5. Click OK.
  6. You should now see the new site added to the search list (and checked). Click Finish.
  7. In the subsequent Search Results dialog box, select the checkbox for Android Plugin > Developer Tools. This will check both features: "Android Developer Tools", and "Android Editors". The Android Editors feature is optional, but recommended. If you choose to install it, you need the WST plugin mentioned earlier in this page. Click Next.
  8. Read the license agreement and then select Accept terms of the license agreement. Click Next.
  9. Click Finish.
  10. The ADT plugin is not signed; you can accept the installation anyway by clicking Install All.
  11. Restart Eclipse.
For Eclipse 3.4 (Ganymede):
  1. Start Eclipse, then select Help > Software Updates....
  2. In the dialog that appears, click the Available Software tab.
  3. Click Add Site...
  4. Enter this as the Location:https://dl-ssl.google.com/android/eclipse/ or http://dl-ssl.google.com/android/eclipse/
  5. Click OK.
  6. Back in the Available Software view, you should see the plugin. Select the checkbox next to Developer Tools and click Install...
  7. On the subsequent Install window, "Android Developer Tools", and "Android Editors" should both be checked. The Android Editors feature is optional, but recommended. If you choose to install it, you need the WST plugin mentioned earlier in this page. Click Next.
  8. Accept the license agreement and click Finish.
  9. Restart Eclipse.
Now, you just need to modify your Eclipse preferences to point to the Android SDK directory:
  1. Select Window > Preferences... to open the Preferences panel.
  2. Select Android from the left panel.
  3. For the SDK Location in the main panel, click Browse... and locate the SDK directory where you kept Android SKD (e.g. C:\android-sdk-windows-1.0_r2)
  4. Click Apply, then OK.
Done eclipse is ready now to start with a HelloWorld Andorid application.

Step 1:
Create a new Android project as shown bellow.




Step 2:
Enter project name, package name, activity name and application name then click onfinish.




Step3:
we get project directory structure as given bellow



Step4:
Locate the java source HelloAndroid.java code file and change the new code as given here.



package com.hello.android;

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

public class HelloAndroid extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv=new TextView(this);
tv.setText("My First Android");
this.setContentView(tv);
}
}

Step 5:
Save the code and run the project. Select given option bellow



Step 6:
The android emulator will come, it would be bit slow and gradually one menu button will come then click on it. We get a menu as shown bellow and Hello Android icon will appear, click on it




Step 7:

Final out put will be here




we can also work with main.xml and strings.xml for designing user interface then steps are as follows



Step1:
Edit the main.xml as bellow



Step2:
Edit the strings.xml as bellow



here strings.xml used for Label values and main.xml used for layout the interface. and finally see the code of HelloAndroid.java will be like this. which actualy load the main.xml.

package com.hello.android;

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

public class HelloAndroid extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

save and run the project and verify the output.

NB: R.java actually generates automatically. you can design the project either way.


0 comments:

Post a Comment