Simple Android EventBus Project
Greenrobot’s EventBus is a tiny library that allows publish-subscribe style communication between components without requiring the components to explicitly register with one another.
That makes the data exchange between components like Activity, Fragment, Services and any kind of backgrounds threads pretty easy.
EventBus.getDefault().register(this);
EventBus.getDefault().unregister(this);
@Subscribe
public void onEvent(MessageEvent event) {
Toast.makeText(this, "Hey, my message" + event.getMessage(), Toast.LENGTH_SHORT).show();
}
EventBus.getDefault().postSticky(new MessageEvent("Hey event subscriber!"));
EventBus.getDefault().post(new MessageEvent("Hey event subscriber!"));