EventBus报错: No subscribers registered for event class com.example.smartcity.pojo.login.Account4Result
No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent
EventBus报错:
No subscribers registered for event class com.example.smartcity.pojo.login.Account4Result
No subscribers registered for event class org.greenrobot.eventbus.NoSubscriberEvent
回调方法被private修饰。这是私有的,要把它改成public。
@Subscribe(threadMode = ThreadMode.MAIN)
private void onRegisterInfo(Register4Result register4Result) {
Log.i("onRegisterInfo:", register4Result.getMsg());
if (register4Result.getCode() == 200) {
Toast.makeText(this, "注册成功!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "注册失败!", Toast.LENGTH_SHORT).show();
}
}
回调方法被protected 修饰。这是受保护的,要把它改成public。
@Subscribe(threadMode = ThreadMode.MAIN)
protected void onRegisterInfo(Register4Result register4Result) {
Log.i("onRegisterInfo:", register4Result.getMsg());
if (register4Result.getCode() == 200) {
Toast.makeText(this, "注册成功!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "注册失败!", Toast.LENGTH_SHORT).show();
}
}
差不多就是这样。
希望可以帮到寻找答案的小伙伴。