From the course: Android Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Send broadcast messages with EventBus

Send broadcast messages with EventBus - Android Tutorial

From the course: Android Development Tips

Send broadcast messages with EventBus

- [Instructor] In a previous tip, I described how to use an intent service to manage a background task. And I showed how to quickly create an intent service using Android Studio and how to add code to start and manage the task. In this tip, I've cleaned up that code a bit so I'm only managing a single task. And in the handleActionFoo method, in the MyIntent service class, I'm logging messages using logcat output. Now I'm going to show you how to communicate back from the intent service to the user interface, which could be an activity or a fragment. An intent service doesn't have a direction connection back to the user interface. So you have to send messages using a broadcast message. You could use the local broadcast manager class that's a part of the support library. And I've shown how to use that in a couple of courses. But in this tip, I'm going to describe how to use a third party open source product called EventBus. This library can help you manage broadcast messages that you…

Contents