The easiest way to communicate through fragments is using EventBus - https://github.com/greenrobot/EventBus
HowTo:
1. Add these line to fragment that needs to get the information:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
EventBus.getDefault().register(this);
return inflater.inflate(R.layout.event_list, container, false);
}
@Override
public void onDestroyView() {
super.onDestroyView();
EventBus.getDefault().unregister(this);
}
public void onEventMainThread(EventBusMsg bus) { //Name your method like this
//here you get the info...
}
2. Post the information from anywhere, like this:
EventBus.getDefault().post(new EventBusMsg(true));
Make class of the object you are going to post:
public class EventBusMsg {
//some info...
}