org.greenrobot.eventbus.EventBusException: Subscriber class com.nkbh.sevenday.mymodeldemo.MainActiv

在fragment中使用EvenBus时

EventBus.getDefault().register(getActivity());

直接报错:

org.greenrobot.eventbus.EventBusException: Subscriber class com.nkbh.sevenday.mymodeldemo.MainActivity and its super classes have no public methods with the @Subscribe annotation

org.greenrobot.eventbus.EventBusException: Subscriber class com.nkbh.sevenday.mymodeldemo.MainActiv_第1张图片

原因:register方法传入的是this,而不是context

代码修改成:

EventBus.getDefault().unregister(this);

你可能感兴趣的:(Android,EvenBus)