Fix bug 2142296 where the user couldn't back out of the JetBoy demo.

The application was trapping the key up event on the back key. It
worked on Donut because the framework implemented the "back" behavior
on the key down. The fix consists in sending the key up event on the
back button to the Activity class.
This commit is contained in:
Jean-Michel Trivi
2009-09-28 15:06:25 -07:00
parent 3a68366197
commit c94b435b86

View File

@@ -133,19 +133,22 @@ public class JetBoy extends Activity implements View.OnClickListener {
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent msg) {
if (keyCode == 4)
super.onKeyDown(keyCode, msg);
return mJetBoyThread.doKeyDown(keyCode, msg);
if (keyCode == KeyEvent.KEYCODE_BACK) {
return super.onKeyDown(keyCode, msg);
} else {
return mJetBoyThread.doKeyDown(keyCode, msg);
}
}
/**
* Standard override for key-up. We actually care about these, so we can
* turn off the engine or stop rotating.
* Standard override for key-up.
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent msg) {
return mJetBoyThread.doKeyUp(keyCode, msg);
if (keyCode == KeyEvent.KEYCODE_BACK) {
return super.onKeyUp(keyCode, msg);
} else {
return mJetBoyThread.doKeyUp(keyCode, msg);
}
}
}