Pressing menu button causes crash in Activity with no ActionBar Pressing menu button causes crash in Activity with no ActionBar android android

Pressing menu button causes crash in Activity with no ActionBar


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:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.3_r1/android/support/v7/app/ActionBarImplICS.java#ActionBarImplICS.getThemedContext%28%29

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:

@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {    if ( keyCode == KeyEvent.KEYCODE_MENU ) {        // do nothing        return true;    }    return super.onKeyDown(keyCode, event);}