Skip to content Skip to sidebar Skip to footer

How To Exit Android Application From Exit Button?

Possible Duplicate: android - exit application code I am finding the way to exit android application to home screen(android phone). My code is not completely exit application bu

Solution 1:

public void AppExit()
{

    this.finish();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

    /*int pid = android.os.Process.myPid();=====> use this if you want to kill your activity. But its not a good one to do.
    android.os.Process.killProcess(pid);*/

}

call this method where you click exit button


Post a Comment for "How To Exit Android Application From Exit Button?"