I created an android application with a logout option in onCreateOptionsMenu. The Logout works perfectly but when I press the back button again it takes me to t
To Finish an Activity I'm using this code:
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);
} //close method
or kill Process with this code:
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);