Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
Passing Data Between Two Fragments
In Chapter 13, you passed a crime’s ID from CrimeListFragment to CrimeDetailFragment. Passing data to DialogFragment destinations works just the same.
What is different this time is that you are also passing a result back to CrimeDetailFragment: When the user selects a new date, CrimeDetailFragment needs the date to update its UI. Instead of using the Navigation library to handle that communication, this time you will rely on the Fragment Results API. Its usage is slightly different than the Activity Results API you used back in Chapter 7, but the concepts are the same, so you should feel right at home.
The conversation between your fragments will look like Figure 14.4. When the DatePickerFragment ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access