Reputation: 3273
I don't know why , i can't override back button: I tried everything I know to override my back button.
And fragment.addToBackStack(null)
don't work .
Any one have an explanation?
I am using android 3.0, and i have activity containing 4 frameLayout where i associate fragments.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return false;
}
return super.onKeyDown(keyCode, event);
}
Upvotes: 1
Views: 992
Reputation: 1243
You should return true if you have handled the key event, this will stop any callbacks to propagate to the android os for handling of the event. http://developer.android.com/reference/android/view/View.html#onKeyDown(int, android.view.KeyEvent) So change from return false; to return true; and you should be good. And do put some logging in there to make it clear what path is being executed :)
Upvotes: 1