After reading the question Basic communication between two fragments and the link given in the accepted answer, I have a question. Why don't I communicate between fragments using local broadcasts as long as I need to pass primitive types?
Note that LocalBroadcastManager
has been deprecated for some time now. This means that it is no longer a recommended solution for anything, including communicating between fragments.
It should also be noted that LocalBroadcastManager
is synchronous communication - it requires the listener to be actively listening when the broadcast is sent. In cases where you are communicating a result to a fragment on the back stack, that fragment on the back stack is stopped and shouldn't be listening at all until you return to that fragment and it is started again. This is something all of the recommended patterns already handle for you.