To communicate data between Fragment
s and a host Activity
or the Activity
’s other Fragment
s, it’s considered best practice to do so through the host Activity
—this makes the Fragment
s 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 (, or ), or finishes editing an existing contact or adding a new one.