I'm parsing JSON
with Async Http
in Activity. Once when the data is successfully parsed, I want it to be available to both Fragments that the Activity is holding. One fragment is a ListView
displaying the downloaded data and the other is a Google MapView
displaying the data - not that it matters.
Once the data is downloaded:
@Override
public void onSuccess(int statusCode, Header[] headers, String responseString) {
// Data downloaded
}
I want to send it to both of those fragments
and update the Map and ListView
with data.
So I somehow want to implement some kind of listener in both of those fragments that will listen for "onSuccess"
to occur and then use the data that it retrieved.
So if onSuccess
occured before Fragments
even instantiated, they will instantly display data. If not, they will wait for it.
Could someone help me implement this? I don't know how exactly to approach this.
You have these options :
((MyActivity)getActivity()).getData();