Pass data through Fragment Manager

With Android Jetpack components a lot of things are happening here and there. Nowadays most of the developers tend to use Single Activity architecture, with that communicating between fragments become more crucial.

There are multiple ways to communicate between fragments. For example, using Interfaces or a shared ViewModel. But, this is sometimes additional overhead. As an alternative setTargetFragment could be used but, this is also now deprecated.

So, let's look at the modern way.

The modern way

Beginning from Fragment release 1.3.0-alpha04 and onwards FragmentManager can be used to communicate between fragments. …

Nishan Wijesinghe

Android Engineer @Vinted https://swnishan.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store