Day126 — pass data back to source fragment
1 min readDec 2, 2019
A common scenario in android application is that some data is needed to send back to the source from the destination fragment.
Let define the scenario as below:
- source fragment starts destination fragment
- new data occurs in destination
- destination want to pass that data back to source
For Activity, you can use setResult
to pass intent back to the source activity
For fragment, you can use setTargetFragment
to state the who is the source so that that is a reference to the source fragment in destination fragment. Data can be easily passed back to source using intent.