Pressing Menu Button Causes Crash In Activity With No Actionbar
I'm a newbie in Android and working on my first app. I have the main activity with no ActionBar in it. And I don't want to display any menu in that Activity. Everything is working
Solution 1:
My guess is that this is a bug in the AppCompat library. If you take a look at the code for ActionBarImplICS.getThemedContext() you see that it's the mActionBar that is null:
My guess is that you're using an activity without a title (and thus also without an actionbar):
requestWindowFeature(Window.FEATURE_NO_TITLE);
If I remove this and launch the activity with a title/actionbar I haven't been able to reproduce the crash. Now, running the app with a titlebar when you don't want or need one isn't a very good option. My suggestion is that you override the Menu key press. The app stopped crashing for me when I did this:
@OverridepublicbooleanonKeyDown(int keyCode, KeyEvent event) {
if ( keyCode == KeyEvent.KEYCODE_MENU ) {
// do nothingreturntrue;
}
returnsuper.onKeyDown(keyCode, event);
}
Solution 2:
Looks like this will be fixed in the next support library release http://code.google.com/p/android/issues/detail?id=61394
Post a Comment for "Pressing Menu Button Causes Crash In Activity With No Actionbar"