Possible Duplicate:
android pressing back button should exit the app
I am trying to close an app using mobile's back button. Currently I am overriding onKeyPressed
method and calling moveTaskToBack(true);
. It does hides the app but does not close it. It still remains in the memory. How can I close the app by pressing the back button?
Here is my code
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}