Skip to main content

Android HelloWorld Example


After install android Create New Android Helloworld Application.
1) HelloWorld.java
package co.in.helloworld;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

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);
        System.out.println("Hello World......");
       
    }
}

2) res/layout/main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" /> (We can write own text in between " ")

</LinearLayout>

3) res/values/string.xml(Optional step)


<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="hello">Hello World, HelloWorldActivity!</string>
    <string name="app_name">HelloWorld</string>

</resources>

4) AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="co.in.helloworld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".HelloWorldActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

5) Run Android Application and Got Output in Emulator.







Comments

Popular posts from this blog

Login Application using Database with dialog demo

Follow Below Steps for make simple login applicaiton in Android using database with Dialog demo. 1)DataBaseDemoActivity.java This file diplay login page and trasfer two edit text data into second activity........  package database.co.in; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; public class DataBaseDemoActivity extends Activity implements OnClickListener {     /** Called when the activity is first created. */     EditText mtxt_email, mtxt_password;     Button mLogin; @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.main);         mtxt_email = (EditText)findViewById(R.id.editEmail_id);   ...

Camara Application in Android(Use Hardware Camara)

hi .... write Following code in your project first create camaratest android project....... this example for take image and view in below image view check it........ and enjoy 1) CamaratestActivity.java   package com.in.test; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.hardware.Camera; import android.hardware.Camera.PictureCallback; import android.hardware.Camera.ShutterCallback; import android.os.Bundle; import android.os.Handler; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ImageView; /*  * O@K tech...  */ public class CamaratestActivity extends Activity implements SurfaceHolder.Callback ,OnClickListener { Camera camera; SurfaceView surfaceview;     SurfaceHolder mHolder ;     Button btnSnap; ...

WebApp in Android

First Create Simple Android Project(webapp).   We need WebView in xml for Develop WebApp in Android . So Following Step are Create simple   WebApp in android. 1) res/layout/main.xml   paste following code in main.xml <?xml version="1.0" encoding="utf-8"?> <WebView  xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/webview"     android:layout_width="fill_parent"     android:layout_height="fill_parent" /> 2)webapp.java following Activity is open google.com page in webview. import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; import org.apache.cordova.*; public class webapp extends Activity { @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); WebView wb = (WebView)findViewById(R.id.webview); wb.loadUrl(...