Fork me on GitHub

EventBus Demo

Posted on 16 January 2015
Under Blog
EventBus Demo | Jay Rambhia’s Blog

I have started working on a new application and for this I was looking for ways to communicate between Service and Activity. I found out about EventBus. Eventbus is really easy to use and can be used to communicate between any Objects. EventBus communication happens by posting parcelable classes around. I will not beat around the bush much and jump in the vague details.


To try out EventBus, I made a small demo application. Activity sends data to a background service using EventBus. The service running in background process the data sends the result to the Activity. This turned out to be very easy.

Notes about EventBus

Before I bagan, I jotted down few important things about EventBus.

  • If you want to receive some event, you need to register your class with EventBus.
  • If you have registered your class with EventBus, you must have a method public void onEvent(SomeEventType event) where SomeEventType is what you are expecting.
  • Unregister your class when not required.


Get text from EditText and send to Service.


Process incoming data and send result to Activity

This was fairly easy. You can get demo application source here. EventBusDemo

P.S. A lot of new things to learn ahead.

If you liked - EventBus Demo and found it helpful, please share it with your fellow developers.

comments powered by Disqus

If you have some feedback or questions regarding this post, please add comments. I'd be happy to get some feedback.

If you liked this post, then you should follow Jay on twitter too. He would be excited to know that you like his work.