File File - 1 month ago 25
Android Question

Communicate with fragment in backstack

I have problem with communicating between fragments. In first fragment I use listener to notify activity to open second fragment and pass him some data with Bundle. First fragment is in the backstack. Then, the second fragment opens and does some work with data. After it's finished, fragment should be closed and first fragment should be appear from backstack, but it should be notified about the changed data in second fragment. So, my question is how to notify first fragment that data is changed in second fragment?

Answer

If you want something more sophisticated for sending complex data, use Otto http://square.github.io/otto/ or EventBus https://github.com/greenrobot/EventBus. Or you can use the LocalBroadcastManager.