使用EventBus框架报异常:its super classes have no public methods with the @Subscribe annotation
来源:互联网 发布:python help 函数 编辑:程序博客网 时间:2024/06/04 19:49
今天看了旗舰的博客http://blog.csdn.net/harvic880925/article/details/40660137中关于EventBus框架的介绍,然后自己就去依葫芦画瓢的敲了一下代码,等到运行的时候报异常了
Caused by: org.greenrobot.eventbus.EventBusException: Subscriber class com.wenxia.testdemo.EventBusFirstActivity and its super classes have no public methods with the @Subscribe annotation
然后又看了一下https://github.com/greenrobot/EventBus中的集成步骤
1.定义事件
public static class MessageEvent { /* Additional fields if needed */ }
2.准备订阅者:声明和批注你订阅的方法,可以选择指定线程模式
@Subscribe(threadMode = ThreadMode.MAIN) public void onMessageEvent(MessageEvent event) {/* Do something */};
注册和注销您的订阅服务器。例如在安卓系统,活动和碎片应该通常注册根据他们的生命周期︰
@Overridepublic void onStart() { super.onStart(); EventBus.getDefault().register(this);}@Overridepublic void onStop() { super.onStop(); EventBus.getDefault().unregister(this);}
3.传递事件
EventBus.getDefault().post(new MessageEvent());
原来是要在onMessageEvent(MessageEvent event)方法上面加上@Subscribe,然后再次运行就没问题了
0 0
- 使用EventBus框架报异常:its super classes have no public methods with the @Subscribe annotation
- EventBus报错:and its super classes have no public methods with the @Subscribe annotation
- Eventbus注册异常:its super classes have no public methods with the @Subscribe annotation
- 关于eventbus报错its super classes have no public methods with the @Subscribe的问题
- AndroidStudio关于EventBus报错解决方法its super classes have no public methods with the @Subscribe
- EventBus3.0报错..its super classes have no public methods with the @Subscribe annotation
- 异常 EventBusException:its super classes have no public methods with the @Subscribe annotation
- 异常 EventBusException:its super classes have no public methods with the @Subscribe annotation
- 【Android】AndroidStudio关于EventBus报错解决方法its super classes have no public methods with the @Subscribe
- MainActivity and its super classes have no public methods with the @Subscribe annotation
- Subscriber class xxx.xxx.xxx and its super classes have no public methods with the@Subscribe annotat
- Subscriber class xxx.xxx.xxx and its super classes have no public methods with the@Subscribe annotat
- EventBus 注册错误no public methods with the @Subscribe annotation
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- EventBusException: Subscriber class *** and its super classes have no public methods with the @Subsc
- Subscriber class .NewsFragment and its super classes have no public methods
- EventBus的使用及 解决异常Subscriber ****has no public methods called **
- 深度学习十大框架
- git报错:Please move or remove them before you can switch branches.
- SSH框架之Struts的全局跳转视图配置、配置的各项默认值
- RHCE练习题 7.配置端口转发 两种方法
- 关于panic之LOCKUP
- 使用EventBus框架报异常:its super classes have no public methods with the @Subscribe annotation
- 手动配置 ESXi 主机挂载 NFS 的最大值
- FZU Fire Game(两点BFS)
- Linux驱动开发①--Linux基础及hello模块
- Https和Http的区别
- 归并排序法
- TIME_WAIT状态的连接过多是什么原因?
- MD5算法原理与实现
- 查看oracle的归档日志及空间占用率,清除归档日志