exit from application android code example
Example 1: exit app android
ActivityName.this.finish();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
Example 2: Exit program Android
public void onBackPressed() {
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}