i am putting this code in my android activity to handle the back button to get out of the app and stop it but the back button keep move me to the previous activity this is my code , please help me out why it doesn't work :
public boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode == KeyEvent.KEYCODE_BACK) {
System.exit(0);
return true;
}
return super.onKeyDown(keyCode, event);
}
and i have mad a debug it get the right value for key code but still it does not work !!
Edit : well what is really happening that the previous activity is a validation activity activity and i am getting device IMEI because if the device is accepted it will show a dialog and proceed to this activity and when the user press back i want him to get out of the app and i don't want the validation process to start all over again !!! ok?