在BaseActivity的生命onCreate 和 onDestory生命周期方法中调用EventBus的注册和取消注册方法;
子类中没有写任何订阅的方法,报错:
Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class **.views.MainActivity and its super classes have no public methods with the @Subscribe annotation;
请问大神,这个怎么处理?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
题主的问题应该是在BaseActivity注册订阅之后, GreenRobot.EventBus 未找到任何 @Subscribe注解的公有(public)回调函数. EventBus消息订阅根本没有必要写到BaseActivity 或者BaseFragment中, 按需调用就好了.
另外, 值得说明的是:
上述内容是可以在各EventBus框架的wiki文档中找到对应的警告的.
示例如下:
最后强烈建议使用 AndroidKnife/RxBus, 如果你已经使用了Rx的话.