Possible Duplicate:
Home button listener
I use below code to listener home button pressed:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
System.out.println(keyCode);
if(keyCode == KeyEvent.KEYCODE_HOME) {
//do things
return true;
}
return super.onKeyDown(keyCode, event);
}
Why it no response?
I try to show the keyCode.
While I press other button, it show keycode.
Only press home button, it does show.
How can I modify it?
you can’t catch whether the home button was pressed .
onKEyDown()doesn’t seem to work for HOME Android has kept the functionality of home button separate from other keys. The preferred way is to deal with onStop() of your Activity being called when the user presses HOME.