On pressing the back button, I\'d like my application to go into the stopped state, rather than the destroyed state.
In the Android docs it states:
Working example..
Make sure don't call super.onBackPressed();
@Override
public void onBackPressed() {
Log.d("CDA", "onBackPressed Called");
Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);
}
In this way your Back Button act like Home button . It doesn't finishes your activity but take it to background
Second way is to call moveTaskToBack(true);
in onBackPressed
and be sure to remove super.onBackPressed