美文网首页
EventBus3.0

EventBus3.0

作者: 叁分钟热血 | 来源:发表于2018-03-27 17:08 被阅读30次

在一个Activity中注册EventBus.getDefault().register(this)出现以下错误:

Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class *** and its super classes have no public methods with the @Subscribe annotation

出现这个异常有两种情况:


1、就是网上大多数的情况,在接收EventBus消息的方法必须是public的,还有必须注释@Subscribe(threadMode = ThreadMode.MAIN)ps:线程自己选择

2、我今天遇到一个情况是在注册EventBus.getDefault().register(this)的类中没有写接收消息的方法,也会提示这个错误。

总结:在注册EventBus.getDefault().register(this)的类中,必须要有接收的地方,而且要符合规范的书写。

相关文章

网友评论

      本文标题:EventBus3.0

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