Issue
I was wondering if it's possible to have 1 listener listen for a specific event throughout the whole application.
At this moment I have created my own listener which is listening for an event to happen, however it should still listen to this event when I switch to another activity.
Solution
Use http://square.github.io/otto/ for event listening.
This is an example of usage:
Bus bus = new Bus();
bus.post(new AnswerAvailableEvent(42));
@Subscribe public void answerAvailable(AnswerAvailableEvent event) {
// TODO: React to the event somehow!
}
bus.register(this); // In order to receive events, a class instance needs to register with the bus.
Answered By - Bogdan Ustyak
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.