The project describes how to write an activity with the use of helloworld example.
Underlying Algorithm:
Basic description of algorithm in step by step form:
- Create a HelloWorld Project.
- It will generate some default files like HelloWorld .java, main.xml, AndroidManifest.xml, Strings.xml.
- The AndroidManifest.xml defines an Activity which is the entry for any android application. An application can have at least one or more activity but every activity must be declared in AndroidManifest.xml
- The main.xml declares the user interface in XML.
- The strings.xml declares the text to be displayed in application.
- The HelloWorld class contains onCreate() method by default which is called when the activity is first created.
- In onCreate() method setContentView() method gets called which sets the view to setContentView (R.layout.main) by default. Here R is resource class of android which gets created automatically and which contains various layouts of the application in the form of xmls.
Steps to Create:
1 Open Eclipse. Use the New Project Wizard and select Android Project. Give the respective project name i.e. HelloWorld

2. Then enter the following information:
Project name: HelloWorld
Build Target: Android 1.6
Application name: HelloWorld
Package name: org.example.HelloWorld
Create Activity: HelloWorld

3. On Clicking Finish HelloWorld code structure is generated with the necessary Android Packages being imported along with HelloWorld.java class and public void onCreate(Bundle savedInstanceState) method.
package org.example.HelloWorld;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Output –The final output:
