EventBus
EventBus copied to clipboard
No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent
@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.
Maybe your event is fired before your activity/fragment is started or after it is stopped? -Uwe
- When your app goes to background and then back to foreground, current Activity is the activity you register eventBus?
- When your app goes to background and then back to foreground, you register EventBus by onStart, but when you post object from Activity ?