@Override public boolean onOptionsItemSelected(MenuItem item) { if (!isUserVisible()) { // Unclear how this is happening. Current theory is that this fragment was scheduled // to be removed, but the remove transaction failed. When the Activity is later // restored, the FragmentManager restores this fragment, but Fragment.mMenuVisible is // stuck at its initial value (true), which makes this zombie fragment eligible for // menu item clicks. // // Work around this by relying on the (properly restored) extra user visible hint. LogUtils.e( LOG_TAG, "ACVF ignoring onOptionsItemSelected b/c userVisibleHint is false. f=%s", this); if (LogUtils.isLoggable(LOG_TAG, LogUtils.DEBUG)) { LogUtils.e(LOG_TAG, Utils.dumpFragment(this)); // the dump has '%' chars in it... } return false; } boolean handled = false; final int itemId = item.getItemId(); if (itemId == R.id.inside_conversation_unread) { markUnread(); handled = true; } else if (itemId == R.id.show_original) { showUntransformedConversation(); handled = true; } return handled; }