I want to finish the Activity on Home Button Click .
I have below code but not get its click event . but still not get clickevent
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_HOME:
System.out.println("Home clicked....");
return true;
}
}
return super.onKeyDown(keyCode, event);
}
When Home button is pressed, onStop method is called in your activity. So what you may do is to add
finish();in onStop method to destroy your activity. Eventually onDestroy method will be raised to confirm that your activity is finished.