EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent

Open artem1989 opened this issue 5 years ago • 2 comments

 @Override
    public void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

 @Override
    public void onStop() {
        EventBus.getDefault().unregister(this);
        super.onStop();
    }

// post object from Activity
ByteImage msg = new ByteImage();
EventBus.getDefault().postSticky(msg);

// subscriber placed in other module
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN)
   public void writeImage(ByteImage image) {
        write(image); // not invoked after app back from background to foreground
 }

When app just started everything works perfectly but after app goes to background and then back to foreground: No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent for event class ByteImage. Register and unregister called as intended.

artem1989 avatar Apr 16 '19 16:04 artem1989

Maybe your event is fired before your activity/fragment is started or after it is stopped? -Uwe

greenrobot-team avatar Apr 30 '19 05:04 greenrobot-team

  1. When your app goes to background and then back to foreground, current Activity is the activity you register eventBus?
  2. When your app goes to background and then back to foreground, you register EventBus by onStart, but when you post object from Activity ?

xianfeng92 avatar May 05 '19 03:05 xianfeng92