I will prefer you to use EventBus for communication between Classes,Fragments,Services whatever it may be.It is very simple, most reliable and efficient.
It can be achieved in just 3 Steps:
1.Define Events.
public static class MessageEvent { /* Additional fields if needed */ }
2.Prepare subscribers: Declare and annotate your subscribing method, optionally specify a thread mode:
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageEvent(MessageEvent event) {/* Do something */};
Register and unregister your subscriber. For example on Android, activities and fragments should usually register according to their life cycle:
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
3.Post Events.
EventBus.getDefault().post(new MessageEvent());
For more Details You can check here.
Hope it may help you.