Otto event without firing

I have an action, and it launches the DialogFragment dialog, at the end of the event, DialogFragment sends the event to the Otto event bus, this should trigger the parent method in it. I posted the related code here, the same code still works where it is in my application, but here the event simply does not fire.

Code in action ...

@Subscribe public void OttoUpdateUI(BudgetUpdateObject budgetUpdateObject) { updateUI(); Log.d("budget", "Otto updateUI called"); } @Override public void onResume() { super.onResume(); BusStand.getInstance().register(BudgetActivityNew.class); } @Override public void onPause() { super.onPause(); BusStand.getInstance().unregister(BudgetActivityNew.class); } 

BusStand Class ....

 public final class BusStand { private static final Bus BUS = new Bus(); public static Bus getInstance() { return BUS; } private void BusProvider() { } } 

and shooting event ...

 BusStand.getInstance().post(new BudgetUpdateObject()); 

I checked the import in this operation, and I do not use the dagger module, and I do not use any other event bus. Any help would be much appreciated.

So I start DialogFragment from activity ....

 AddBudgetDialogFragment addBudgetDialogFragment = new AddBudgetDialogFragment(); addBudgetDialogFragment.setStyle(DialogFragment.STYLE_NO_TITLE,0); addBudgetDialogFragment.show(getSupportFragmentManager(),"DialogFragment"); 
+6
source share
4 answers

Found the answer thanks to these guys ... AndroidAnnotations was a redefinition @ subscription, so my subsrcibed event never fired, found it using breakpoints .... Too bad, I moved to EventBus, and everything works fine .... I like that really loved otto ...

+1
source

The problem is that you are not registering an instance of activity , you are registering a class:

BusStand.getInstance () register (BudgetActivityNew.class) ;.

You must change the code to:

BusStand.getInstance () register (this) ;.

That should do it. :)

+5
source

In my case, I imported the wrong library class into my class. Check your import ~

For me, replacing:

 import com.google.common.eventbus.Subscribe; 

with this:

 import com.squareup.otto.Subscribe; 

Hope this helps someone.

+1
source

You need to register DialogFragment to Bus . Submit the code for your DialogFragment so I can help you.

-2
source

All Articles