From Fragments to Activity: the Lambda Way

1 · Groupon · Sept. 29, 2017, 12:07 a.m.
Activities have their lifecycle, and the same goes forFragments. Hence, communication from Fragments to Activities is notoriously problematic.The communication between Fragments and Activities cannot be as simple as passing a listener to the fragment that the activity could implement: the Activity would soon rotate and the Fragment would keep a reference to an Activity that had died and would leak. Google recommends a “good old pattern” to achieve this goal and limit the risk of leaks. In this a...