Thursday, March 10, 2011

[android-developers] override back button

Can someone help me understand how to stop the back button from
exiting out of my program? I want it to just return to my main menu
or exit if pressed on the main menu but when I override the method it
still exits. Here is what I currently have:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()
== 0) {
if (animation.state != 1){
animation.state = 1;
return true;
}
else return false;
}

return super.onKeyDown(keyCode, event);
}

I have messed with it a little but my program is always still closes.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate