I have the following code in my Activity. I have Breakpoints set to all of these methods. When I press the Menu button, it enters onKeyDown and onKeyUp. When I press the back button, the app closes and phone goes back to home screen without passing any of my breakpoints.
EDIT: This could should work according to most sources:
@Override
public void onBackPressed() {
SwitchToMenuState();
}
However, it doesn't. I have tried all permutations of the following code blocks, and neither of them ever get called:
@Override
public void finish()
{
SwitchToMenuState();
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
SwitchToMenuState();
}
return true;
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
SwitchToMenuState();
}
return true;
}
I am using Android 2.3 and Processing, although it doesn't seem to be related to Processing at all. Eclipse tells me that I am overriding android.app.Activity.onBackPressed.