Saturday, August 6, 2011

android list view with adepter , aleart dialoge box EXAMPLE IN ANDROID



public class ListviewandroidActivity extends Activity {
/** Called when the activity is first created. */
TextView selection;

private ListView lv1;
private String lv_arr[]={"Android","iPhone","BlackBerry","AndroidPeople","Algeria", "Argentina", "Australia",
"Brazil", "Cote d'Ivoire", "Cameroon",
"Chile", "Costa Rica", "Denmark",
"England", "France", "Germany",
"Ghana", "Greece", "Honduras",
"Italy", "Japan", "Netherlands",
"New Zealand", "Nigeria", "North Korea",
"Paraguay", "Portugal","Serbia",
"Slovakia", "Slovenia", "South Africa",
"South Korea", "Spain", "Switzerland",
"United States", "Uruguay"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
selection=(TextView)findViewById(R.id.textView1);

lv1=(ListView)findViewById(R.id.ListView01);
// By using setAdpater method in listview we an add string array in list.
lv1.setAdapter(new ArrayAdapter(this,android.R.layout.simple_list_item_1, lv_arr));
lv1.setTextFilterEnabled(true);

lv1.setOnItemClickListener(new OnItemClickListener()
{

@Override
public void onItemClick(AdapterView a, View v, int position, long id) {

AlertDialog.Builder adb=new AlertDialog.Builder(ListviewandroidActivity.this);
adb.setTitle("LVSelectedItemExample");
adb.setMessage("Selected Item is = "+lv1.getItemAtPosition(position));
adb.setPositiveButton("Ok", null);
adb.show();

}
});

}



}



............
main.xml
...............



http://schemas.android.com/apk/res/android">








--
krishnachary

MAPS AND LOCATIONS EXAMPLE

1 ONLY ON LOCATION EXAMPLE , 2 MAPS AND LOCATIONS EXAMPLE
==============================

1 ONLY ON LOCATION EXAMPLE
------------------------------------------------
package com.gps;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class GPSLocation extends Activity {



protected LocationManager locationManager;

protected Button retrieveLocationButton;

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

retrieveLocationButton = (Button) findViewById(R.id.btn);

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0,0,new MyLocationListener());

retrieveLocationButton.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
showCurrentLocation();
}
});

}

protected void showCurrentLocation() {

Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

if (location != null) {
String message = String.format(
"Current Location \n Longitude: %s \n Latitude: %s",location.getLongitude(), location.getLatitude()
);
Toast.makeText(GPSLocation.this, message,Toast.LENGTH_LONG).show();
}

}

private class MyLocationListener implements LocationListener {

public void onLocationChanged(Location location) {
String message = String.format( "New Location \n Longitude: %s \n Latitude: %s",location.getLongitude(), location.getLatitude());
Toast.makeText(GPSLocation.this, message, Toast.LENGTH_LONG).show();
}

public void onStatusChanged(String s, int i, Bundle b) {

Toast.makeText(GPSLocation.this, "Provider status changed",Toast.LENGTH_LONG).show();
}


public void onProviderDisabled(String s) {
Toast.makeText(GPSLocation.this,
"Provider disabled by the user. GPS turned off",Toast.LENGTH_LONG).show();
}

public void onProviderEnabled(String s) {
Toast.makeText(GPSLocation.this,
"Provider enabled by the user. GPS turned on",Toast.LENGTH_LONG).show();
}

}
}


***************************


2 MAPS AND LOCATIONS EXAMPLE
--------------------------------------------------


mapsimple example
----------------------------
package com.map;


import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.os.Bundle;

public class HelloGoogleMaps extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);

mapView.setBuiltInZoomControls(true);
}

/*DefaultHttpClient client = new DefaultHttpClient();

String proxyHost = android.net.Proxy.getHost(this);
if (proxyHost !=null) {
int proxyPort = android.net.Proxy.getPort(this);

HttpHost proxy = new HttpHost("*********", ***);

client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}
}
*/
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
*****************************
mapexample 2
-----------------------
package com.wissen.android;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ZoomControls;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class Hello extends MapActivity implements LocationListener {
/** Called when the activity is first created. */

EditText txted = null;

Button btnSimple = null;

MapView gMapView = null;

MapController mc = null;

Drawable defaultMarker = null;

GeoPoint gp = null;

double latitude = 17.518344, longitude = 78.442383;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Creating TextBox displying Lat, Long
txted = (EditText) findViewById(R.id.id1);
String currentLocation = "Lat: " + latitude + " Lng: " + longitude;
txted.setText(currentLocation);

// Creating and initializing Map
gMapView = (MapView) findViewById(R.id.myGMap);
gp = new GeoPoint((int) (latitude * 1000000), (int) (longitude * 1000000));
//gMapView.setSatellite(true);
mc = gMapView.getController();
mc.setCenter(gp);
mc.setZoom(14);

// Add a location mark
MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
List list = gMapView.getOverlays();
list.add(myLocationOverlay);

// Adding zoom controls to Map
ZoomControls zoomControls = (ZoomControls) gMapView.getZoomControls();
zoomControls.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));

gMapView.addView(zoomControls);
gMapView.displayZoomControls(true);

// Getting locationManager and reflecting changes over map if distance travel by
// user is greater than 500m from current location.
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);
}

/* This method is called when use position will get changed */
public void onLocationChanged(Location location) {
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
String currentLocation = "Lat: " + lat + " Lng: " + lng;
txted.setText(currentLocation);
gp = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
mc.animateTo(gp);
}
}

public void onProviderDisabled(String provider) {
// required for interface, not used
}

public void onProviderEnabled(String provider) {
// required for interface, not used
}

public void onStatusChanged(String provider, int status, Bundle extras) {
// required for interface, not used
}

protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}

/* User can zoom in/out using keys provided on keypad */
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_I) {
gMapView.getController().setZoom(gMapView.getZoomLevel() + 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_O) {
gMapView.getController().setZoom(gMapView.getZoomLevel() - 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_S) {
gMapView.setSatellite(true);
return true;
} else if (keyCode == KeyEvent.KEYCODE_T) {
gMapView.setTraffic(true);
return true;
}
return false;
}

/* Class overload draw method which actually plot a marker,text etc. on Map */
protected class MyLocationOverlay extends com.google.android.maps.Overlay {

@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Paint paint = new Paint();
shadow=true;

super.draw(canvas, mapView, shadow);

// Converts lat/lng-Point to OUR coordinates on the screen.
Point p = new Point();
mapView.getProjection().toPixels(gp, p);

paint.setStrokeWidth(1);
paint.setARGB(255, 255, 255, 255);
paint.setStyle(Paint.Style.STROKE);

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.marker);

canvas.drawBitmap(bmp, p.x,p.y, paint);

canvas.drawText("I am here...", p.x, p.y, paint);
return true;
}
}
}




***************************************************
mapexample direction of locations
------------------------------------------------
package com.directions;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection;


public class Directions extends MapActivity {
private MapView map=null;
private MyLocationOverlay me=null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

map=(MapView)findViewById(R.id.map);

map.getController().setCenter(getPoint(17.390777,78.4762));//Center point as Abdies
map.getController().setZoom(14);
map.setBuiltInZoomControls(true);

Drawable marker=getResources().getDrawable(R.drawable.marker);

marker.setBounds(0, 0, marker.getIntrinsicWidth(),marker.getIntrinsicHeight());

map.getOverlays().add(new SitesOverlay(marker));

me=new MyLocationOverlay(this, map);
map.getOverlays().add(me);
}

@Override
public void onResume() {
super.onResume();

me.enableCompass();
}

@Override
public void onPause() {
super.onPause();

me.disableCompass();
}

@Override
protected boolean isRouteDisplayed() {
return(false);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_S) {
map.setSatellite(!map.isSatellite());
return(true);
}
else if (keyCode == KeyEvent.KEYCODE_Z) {
map.displayZoomControls(true);
return(true);
}

return(super.onKeyDown(keyCode, event));
}

private GeoPoint getPoint(double lat, double lon) {
return(new GeoPoint((int)(lat*1000000.0),
(int)(lon*1000000.0)));
}

private class SitesOverlay extends ItemizedOverlay {
private List items=new ArrayList();
private Drawable marker=null;

private GeoPoint abdis=getPoint(17.390777,78.4762); // starting point Abdis
private GeoPoint lakdi=getPoint(17.398804,78.462639); // lakdikapool
private GeoPoint panga=getPoint(17.425994,78.451481);// panjagutta
private GeoPoint ameer=getPoint(17.439424,78.444958);// Ameerpet


public SitesOverlay(Drawable marker) {
super(marker);
this.marker=marker;

items.add(new OverlayItem(getPoint(17.390777,78.4762),"HYD", "Abdis"));
items.add(new OverlayItem(getPoint(17.398804,78.462639),"HYD","Lakdikapool"));
items.add(new OverlayItem(getPoint(17.425994,78.451481),"HYD","Panjagutta"));
items.add(new OverlayItem(getPoint(17.439424,78.444958),"HYD","Ameerpet"));

populate();
}

@Override
protected OverlayItem createItem(int i) {
return(items.get(i));
}

@Override
public void draw(Canvas canvas, MapView mapView,
boolean shadow) {
super.draw(canvas, mapView, shadow);

Projection projection = mapView.getProjection();
Paint paint = new Paint();
paint.setColor(000);
paint.setStrokeWidth(5);
paint.setAlpha(120);



Point point = new Point();
Point point2 = new Point();
Point point3 = new Point();
Point point4 = new Point();


Point point5 = new Point();

projection.toPixels(abdis, point);
projection.toPixels(lakdi, point2);
projection.toPixels(panga, point3);
projection.toPixels(ameer, point4);

canvas.drawLine(point.x, point.y, point2.x, point2.y, paint);// from Abdis to Lakdikapool
canvas.drawLine(point2.x, point2.y, point3.x, point3.y, paint);// from Lakdikapool to panjagutta
canvas.drawLine(point3.x, point3.y, point4.x, point4.y, paint);// from panjagutta to Ameerpet


super.draw(canvas, mapView, shadow);

boundCenterBottom(marker);
}

@Override
protected boolean onTap(int i) {
Toast.makeText(Directions.this,items.get(i).getSnippet(),Toast.LENGTH_SHORT).show();

return(true);
}

@Override
public int size() {
return(items.size());
}
}
}
--
krishnachary

Android database example

Android database example
...............................................



// android db example
--------------------------------



package com.sqlite;


public class SQLiteDataBase extends ListActivity {
public static int Online=1;
ArrayList LISTITEMS=new ArrayList();
public boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(this.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo().isConnectedOrConnecting();

}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();


}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
if(isOnline())
{

}else
{
showDialog(Online);
}
// if(isOnline()==false)
// {
// showDialog(Online);
// }



DBAdapter db = new DBAdapter(this);


setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, LISTITEMS));


//Inserting emp details in to databse.


db.open();

long id;

id = db.insertTitle(1,
"programer1",
"Android Application Developer",
"programer1@gmail.com",1111111);

id = db.insertTitle(2,
"programer2",
"iPhone Developer",
"programer2@gmail.com",2222222);
id = db.insertTitle(3,
"programer3",
"iPhone Developer",
"programer3@gmail.com",333333);

db.close();

// Retriving all the records


db.open();
Cursor c = db.getAllTitles();
if (c.moveToFirst())
{
do {
LISTITEMS.add( c.getString(0));
LISTITEMS.add( c.getString(1));
LISTITEMS.add( c.getString(2));
LISTITEMS.add( c.getString(3));
LISTITEMS.add( c.getString(4));
} while (c.moveToNext());
}

// if(isOnline()==false)
// {
// showDialog(Online);
// }
//
/*
// Retriving a single Record

db.open();
Cursor r = db.getTitle(1);
if (r.moveToFirst())
DisplayTitle(r);
else
Toast.makeText(this, "No title found",
Toast.LENGTH_LONG).show();


*/
/*
//---update title---
db.open();
try{

if (db.updateTitle(3 ,"xyz","C# 2008 Programmer","xyz.abc@gmail.com",1234))

Toast.makeText(this, "Update successful.",Toast.LENGTH_LONG).show();
else
Toast.makeText(this, "Update failed.",Toast.LENGTH_LONG).show();

//---retrieve the same title to verify---
Cursor c = db.getTitle(3);
if (c.moveToFirst())
DisplayTitle(c);
else
Toast.makeText(this, "No title found",

Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
e.printStackTrace();
}

*/

/*
//---delete a title---
db.open();
if (db.deleteTitle(2))
Toast.makeText(this, "Delete successful-1.",
Toast.LENGTH_LONG).show();
if (db.deleteTitle(3))
Toast.makeText(this, "Delete successful-2.",
Toast.LENGTH_LONG).show();


*/
}
public Dialog onCreatDialiog(int id){

switch(id){
//This is a simple Alert Dialog
case 1:

AlertDialog.Builder ab = new AlertDialog.Builder(this);

ab.setTitle("ALERT_DIALOG IN3");
ab.setMessage(" Please enable the internet ");
ab.setIcon(R.drawable.icon);

ab.setPositiveButton("OK", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "OK Button CLicked", Toast.LENGTH_LONG).show();
}

});
ab.setNegativeButton("No I dont agree", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "No Button CLicked", Toast.LENGTH_LONG).show();

}

});

Dialog ad = ab.create();
return ad;
}
return null;
}
/*
//// public Dialog onCreateDialog(int id) {
switch(id){
//This is a simple Alert Dialog
case ALERT_DIALOG:
AlertDialog.Builder ab = new AlertDialog.Builder(this);
ab.setTitle("ALERT_DIALOG IN3");
ab.setMessage(" Example for Alert Dialog PRES BACK TO Dismiss Dialog");
ab.setIcon(R.drawable.icon);

ab.setPositiveButton("OK", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "OK Button CLicked", Toast.LENGTH_LONG).show();
}

});
ab.setNegativeButton("No I dont agree", new DialogInterface.OnClickListener(){

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "No Button CLicked", Toast.LENGTH_LONG).show();

}

});

Dialog ad = ab.create();
return ad;



//This is a Custom Dialog
//New Layout CustomLayout is ceated check res\layout
//check that SetcontentView function is used
case CUSTOM_DIALOG:

Dialog dialog = new Dialog(AllSortsOfDialogs.this);
///////
public void DisplayTitle(Cursor c)
{
Toast.makeText(this,
"eno: " + c.getString(0) + "\n" +
" ename: " + c.getString(1) + "\n" +
"desg: " + c.getString(2) + "\n" +
"email: " + c.getString(3)+"\n"+
"phno: "+c.getString(4),
Toast.LENGTH_LONG).show();
}
*/


}

---------------------------


db file
-------

package com.sqlite;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBAdapter
{
public static final String KEY_NO = "no";
public static final String KEY_NAME = "name";
public static final String KEY_DESG = "desg";
public static final String KEY_EMAIL = "email";
public static final String KEY_PHNO="phno";


// private static final String TAG = "DBAdapter";

private static final String DATABASE_NAME = "employedetails";
private static final String DATABASE_TABLE = "tableone";
private static final int DATABASE_VERSION = 4;

private static final String DATABASE_CREATE =
"create table tableone(no integer primary key , "+ "name text not null, desg text not null, "+ "email text not null," +"phno integer);";

private final Context context;

private DatabaseHelper DBHelper;
private SQLiteDatabase db;

public DBAdapter(Context ctx)
{
this.context = ctx;
DBHelper = new DatabaseHelper(context);
}

private static class DatabaseHelper extends SQLiteOpenHelper
{
DatabaseHelper(Context context)
{
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db)
{
db.execSQL(DATABASE_CREATE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
//Log.w(TAG, "Upgrading database from version " + oldVersion+ " to "+ newVersion + ", which will destroy all old data");
db.execSQL("DROP TABLE IF EXISTS tableone");
onCreate(db);
}
}

//---opens the database---
public DBAdapter open() throws SQLException
{
db = DBHelper.getWritableDatabase();
return this;
}

//---closes the database---
public void close()
{
DBHelper.close();
}

//---insert a title into the database---
public long insertTitle(long no,String name, String desg, String email ,long phno)
{
ContentValues initialValues = new ContentValues();

initialValues.put(KEY_NO, no);
initialValues.put(KEY_NAME, name);
initialValues.put(KEY_DESG, desg);
initialValues.put(KEY_EMAIL, email);
initialValues.put(KEY_PHNO, phno);

return db.insert(DATABASE_TABLE, null, initialValues);
}
//---deletes a particular title---
public boolean deleteTitle(long rowId)
{
return db.delete(DATABASE_TABLE, KEY_NO +"=" + rowId, null) > 0;
}

//---retrieves all the titles---
public Cursor getAllTitles()
{
return db.query(DATABASE_TABLE, new String[] {
KEY_NO,
KEY_NAME,
KEY_DESG,
KEY_EMAIL,KEY_PHNO},
null,
null,
null,
null,
null);
}

//---retrieves a particular title---
public Cursor getTitle(long rowId) throws SQLException
{
Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] {
KEY_NO,
KEY_NAME,
KEY_DESG,
KEY_EMAIL,KEY_PHNO
},
KEY_NO + "=" + rowId,
null,
null,
null,
null,
null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}

//---updates a title---
public boolean updateTitle(long no, String name,String desg, String email,long phno)
{
ContentValues args = new ContentValues();
args.put(KEY_NO, no);
args.put(KEY_NAME, name);
args.put(KEY_DESG, desg);
args.put(KEY_EMAIL, email);
args.put(KEY_PHNO, phno);
return db.update(DATABASE_TABLE, args,KEY_NO , null) > 0;
}
}




--
krishnachary

welcome screen code using Thread and Handler Android Application



WelcomeThread.java
...............................


import android.content.Context;
public class WaitingThread extends Thread{
private    Context c;
private WaitingInterface mWaitingInterface;

public interface WaitingInterface
{
   public void onWaitingAppRerurn(final boolean result);
}
   
public WaitingThread(WaitingInterface ti) {
    mWaitingInterface=ti;
 }              

@Override
    public void run() {
        super.run();
        try {
            sleep(*1000);
            mWaitingInterface.onWaitingAppRerurn(true);
            
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }}}
--------------------------------------------------------------------------------------
WelcomeActivity.java
................................
public class WelcomeActivity extends Activity implements WaitingInterface{
    /** Called when the activity is first created. */
    private final int TEST_REQUEST = 1;
    protected Context mContext;
    protected MediaPlayer mPlayer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);


// How to Remove the title in android Application code        
   requestWindowFeature(Window.FEATURE_NO_TITLE);
// For full screen
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);




       setContentView(R.layout.welcome);

//Background Music for the welcome screen    
//     MediaPlayer example code for android application  


       MediaPlayer mPlayer = MediaPlayer.create(this, R.raw.song1);
       mPlayer.start();

//     mPlayer.setLooping(true);


       mContext=this;
       new WaitingThread(WelcomeActivity.this).start();  

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
  //      mPlayer.stop();
    }


    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }
    
     //How to Use Handler in Android 
    
     public Handler mHandler=new Handler(){
         @Override
        public void handleMessage(Message msg) {
            // TODO Auto-generated method stub
        switch (msg.what) {
            case TEST_REQUEST:
                Boolean isSuccess=(Boolean)msg.obj;
                if(isSuccess){
                     final Intent intent = new Intent(mContext, NextActivity1.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                    finish(); 
                } break;

            default:
            break;}}};
    public void onWaitingAppRerurn(boolean result)
 { mHandler.sendMessage(mHandler.obtainMessage(TEST_REQUEST,new Boolean(result))); }
}