Delete challenge from previous chapter broken on tablet

I completed the delete challenge in chapter 13. Works fine on my phone, not on a tablet. I read other solutions from previous revisions. I understand I simply can’t call getActivity().finish() from my onOptionsItemSelected() within I think my problem is a little different though…when I’m in tablet mode and I press the delete button from the detail fragment side I end up in onOptionsItemSelected() in and not in

This seems to differ from what others are experiencing as others still seem to be able to modify onOptionsItemSelected() in…I can catch the delete case in, but I have no “mCrime” to work with. Am I making an inflation mistake somewhere? Did something change from previous revisions where I actually am in the correct function and the solution this revision is different? Thanks.

When you select a menu option, the system will call onOptionsItemSelected() on the activity, followed by all attached fragments in the order in which they were added. If any of these return true, the menu item has been handled, and this process stops.

Since you do not want to handle the delete option in CrimeListFragment, make sure onOptionsItemSelected() returns false in this case (via the superclass implementation).

That was it. Thank you.

In case anyone else was wondering(I hope this is correct)…from there I let my onCrimeDeleted callbacks do the work. The version just called finish()(for non tablets this is ok). Then the CrimeListActivity callback version displayed the first crime in the detail screen or if the list was empty made the layout visibility “GONE”(just set it again to “VISIBLE” when you select a crime to cover the corner case of deleting everything and attempting to re-add crimes.

The only thing that I’m weird about is my default case catching the up toolbar navigation for non tablets. I noticed allowing the default case to cause a stack overflow was very helpful in catching unexpected selections as from my first post in this thread.

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
            //If we're in a "detail" fragment, we have to update the list side
            //of the tablet.
            Activity activity = getActivity();
            if (activity.findViewById( != null) {
            //Let the callback function in the respected fragment handle what to
            //do from here.
            return true;
            //This handles the case for phones only since if we get here then
            //we've use the toolbar "up" navigation. Our CrimePagerActivity(for phones)
            //will simply call finish().
            return true;