I have a Fragment Activity A, that implements two fragments B and C. On a click of a button, I run a function in the fragment B, to refresh some data coming from internet. When the data is refreshed, I want to update my fragment C (which is a map), with the data I got from fragment B. The problem is that data refresh in fragment B is done through an async task
my code is like that in FragmentActivity A.
...
fragmentB.RefreshData();
Output output = fragmentB.getOutput();
fragmentC.RefreshData(output);
...
Because fragmentB executes an AsyncTask, when I'm doing .getOutput(), the code hasn't properly ended yet, therefore in my fragmentC I'm triggering a nullpointer exception.
My question is, how do I code so that I can wait for the end of the tasks in fragmentB before retrieving my output and pass it to fragmentC ?
Thanks!