美文网首页
org.greenrobot.eventbus.EventBus

org.greenrobot.eventbus.EventBus

作者: jxtx | 来源:发表于2018-05-17 16:40 被阅读68次

    在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


    QQ截图20180517163821.png

    原因:register方法传入的是this,而不是context
    代码修改成:

    EventBus.getDefault().unregister(this);
    

    相关文章

      网友评论

          本文标题:org.greenrobot.eventbus.EventBus

          本文链接:https://www.haomeiwen.com/subject/nctidftx.html