Your activity can implement a custom listener interface on the Activity and use a reference to it in your fragment to pass the communication back.
Android / Fragment - How do I pass parameters of the Last Fragment and send to Previous Fragment?
-
28-06-2023 - |
Question
- I have the following situation: I open the Fragment A and goals, through a click event of the button, go to the Fragment B. When I am in Fragment B and hit the back button (in order to return to the Fragment A) I would like to pass some parameters to Fragment A. Does anyone know how I can do this?
- Thank you in advance to all.
Solution
OTHER TIPS
You can send a broadcast when you hit the back button in Fragment B to Fragment A with the parameters you need put in the bundle, and have broadcast receiver on the Fragment A.
Hope this helps!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow