8.3.2. Communicating Data Between a Fragment and a Host Activity

To communicate data between Fragments and a host Activity or the Activity’s other Fragments, it’s considered best practice to do so through the host Activity—this makes the Fragments more reusable, because they do not refer to one another directly. Typically, each Fragment defines an interface of callback methods that are implemented in the host Activity. We’ll use this technique to enable this app’s MainActivity to be notified when the user selects a contact to display, touches an action bar item (Image, Image or Image), or finishes editing an existing contact or adding a new one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset