I am developing an Android application which has 4 activities. Lets say ActivityA, ActivityB, ActivityC, and ActivityD. Each activity has tablayout so many fragment to display weekly data. I am downloading the data in each activity from Firebase and then passing to fragment which is working fine. I want to fetch all data from Firebase in ActivityA which is deafult activity then I want to pass corrospinding data to each Activity. I have tried to use green robot eventbus library to subscribe but it seems I am not able to fully understand and code it. Would you please suggest me a better way to handle this and please provide some sample if possible.
I have got the answer to this problem. I have used GreenRobot EventBust with postSticky as follows to get the data from publisher activity to all other subscriber activities.
EventBus.getDefault().postSticky(data);
and then in Subscriber Activities
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
public void onEvent(Data data) {
sFullData = data;
viewPager.getAdapter().notifyDataSetChanged();
}
That's all. It worked like a charm.