Saturday 30 July 2011

Hello World - Your First Android App

Recently I was looking into the option of porting my vb.net application to android. So here is a tutorial on how to write your very first android applications.

What you need:

Java knowledge
Java SDK v6.0 or above
MotoDev (Based on Eclispe) - http://developer.motorola.com/docstools/motodevstudio/download/
Android SDK (latest) - http://developer.android.com/sdk/index.html

I also recommend reading about how the android system works, the manifest file, gui file(main) ,R.java etc.


To start out instal JDK, Android SDK and update, MotoDev studio.
Set up a AVD.  
In motoDev now create a new Project and give it a appropiate name.


You will notice that the an Android application is based on the Activity class, and always reference to R.java.


Change the code in activity to corospond with the following:
import android.widget.TextView;


public void onCreate(Bundle savedInstanceState) 
{
       super.onCreate(savedInstanceState);
         TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
   }
 
The enlarged code is the code changed or added.
The onCreate() method is used to start your activity.
In android objects is referred to views. 
TextView will be the equvalint to an Label in .net programming or swing.
Now Run the application.

No comments:

Post a Comment