Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@Subscribe method called multiple time for the same event

Tags:

android

otto

In my code I'm listening for events using @Subscribe anotation:

@Subscribe
public void orderUpdate(OrderUpdateEvent event)

My problem is that this method is called multiple times (1-3 depends from run to run) for the same event object.

This is how I send this event:

busProvider.getEventBus().postOnMain(new OrderUpdateEvent();

What could be the cause of that? Do I'm missing something?

like image 703
skywalker Avatar asked Jan 18 '15 22:01

skywalker


1 Answers

What could be the cause of that?

One possibility is that you have three instances of this class still registered on the event bus. Make sure that you unregister() when the object should no longer receive messages.

like image 193
CommonsWare Avatar answered Oct 15 '22 01:10

CommonsWare