In previous chapters, we have been using different techniques to disseminate data/events/notifications between several Android application components (Activity
, Fragment
, Service
, BroadcastReceiver, …
):
Intents were sent through the system carrying communication messages or notifications to notify a
Service
orActivity
to startBroadcast Intents were used to report a result back from background processes
Handlers were used to communicate between different processes and thread executions
These techniques usually involved a tight coupling between the component that sends the message and the component that receives it. Typically, the sender dispatches a message to a certain receiver and deals with the receiver lifecycle in order to detect any receiver unavailability.
In this chapter, we are going to present to the reader a new construct and pattern, delivered by the EventBus
library, that most of the time simplifies communication between the different...