Event Bus using Green robot and Google guava

Event bus is a concept to pass events between components without knowing to whom the event is sending and who is going to receive the event. Components just push events to event bus and subscribers subscribe to the events will receive the event. Event enables decoupling of components. In android communication between components is cumbersome. This concept, event bus tries to solve the problem.

Green robot' event bus library is a latest in android which has a neat implementation of event bus. Here I am trying to explain the concept of event bus through a simple example. I have a receiver which will listens to events from Power manager. When ever device is charging or discharging, receiver component will push events to event bus. An activity which is subscribed to the event will receive the events and displayed in the screen.

The same example I tried with both libraries green robot and Google Guava.

You can find the green robot sample code in Git hub

The example for Guava implementation of event bus can be found here.

Happy Coding
Team Androidians


Popular posts from this blog

Open Gallery and get the selected image in appplication

Dismiss or Cancel dialog by swipe gesture

AlarmManager and Notification in Android