MainActivity Method onContactDeleted

Method onContactDeleted (Fig. 8.21) from the DetailsFragment.DetailsFragmentListener interface is called by the DetailsFragment to notify the MainActivity when the user deletes a contact. In this case, line 122 pops the DetailsFragment from the back stack. If the app is running on a tablet, line 125 calls the contactListFragment’s updateContactList method to reload the contacts.

118      // return to contact list when displayed contact deleted119      @Override120      public void onContactDeleted()121      {122         getFragmentManager().popBackStack(); // removes top of back stack123 124         if (findViewById(R.id.fragmentContainer) == null) // tablet125            contactListFragment.updateContactList(); ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.