Android Hello world Example – How to write “Hello world” app in android.

Now  a days Android is a most popular operating system led by Google.
In this tutorial i will show you the list of basic android programs to get you start programming in android.

Basic Steps to Develop an Android Application :

  1. Install Android SDK
  2. Install ADT Eclipse plugin
  3. Create an Android Virtual Device (AVD)
  4. Create Android Project with Eclipse (Wizard)
  5. Code it…
  6. Start it in Android Virtual Device (AVD)

Android Hello World Example :

In core Android programming if you want to write hello world program you have to create one textview and its object (here “text”).
Now set the object value as Hello Wold,as shown in below program.

HelloWorldActivity.java :

package com.example.helloworld;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView text = new TextView(this);
text.setText("Hello World");
setContentView(text);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}

Run this as a Android Application 
Here, if you press “Home” button then you can see your hello world application is successfully deployed in your AVD (Android Virtual Device). 



Leave a Reply

Your email address will not be published. Required fields are marked *