I\'m making a game and if the activity is left in any way by the user (back or home key pressed), the activity needs to end the game by posting to a script and ending the activi
Looks like a duplicate of this one
Android, How to receive home button click through broadcast receiver?
@Override
public boolean dispatchKeyEvent(KeyEvent keyevent) {
if (keyevent.getKeyCode() == KeyEvent.KEYCODE_HOME) {
//Do here what you want
return true;
}
else
return super.dispatchKeyEvent(event);
}