I have this problem since I switched to EventBus (the same thing will happen with any bus library), where whenever I want to perform an action when the view is not ready, I get an error that the bus is not registered;
E/EventBus: Could not dispatch event: class com.android.greenfield.Action to subscribing class class com.android.greenfield.GreenStore
This happens when I want to run Action in those parts of the life cycle:
When I take Image / Video :
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
actionsCreator.uploadFile(filepath, "image/jpg");
}
Or here when I get the NAG TAG :
@Override
public void onNewIntent(Intent intent) {
actionsCreator.uploadNfcTag(intent);
}
If I follow the normal path or EventBus , as their document says, I should registeralso unregisteras follows:
@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}
@Override
public void onStop() {
EventBus.getDefault().unregister(this);
super.onStop();
}
, , , , onStart() onStop()... .
@Override
public void onNewIntent(Intent intent) {
dispatcher.register(GreenStore);
actionsCreator.uplaodNfcTag(intent);
dispatcher.register(GreenStore);
}