EventBus使用中遇到的问题
2016-11-24 15:47
92 查看
1.在订阅的页面onCreate中进行注册
2.同时在onDestory中解除注册
4.在需要的地方发布订阅
EventBus 3.0可能出现异常
FATAL EXCEPTION: main
Process: com.hank.rxjavademo, PID: 6329
org.greenrobot.eventbus.EventBusException: Subscriber class com.hank.fragment.map.MapFragment and its super classes have no public methods with the @Subscribe annotation
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:67)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:136)
at com.hank.fragment.map.MapFragment.onCreateView(MapFragment.java:34)
解决方案:
在重写的event方法前加注解 @Subscribe
EventBus.getDefault().register(this);
2.同时在onDestory中解除注册
@Override public void onDestroy() { super.onDestroy(); EventBus.getDefault().unregister(this); }3.重写event(onEvent、onEventMainThread、onEventAsync、onEventBackgroundThread)
4.在需要的地方发布订阅
EventBus.getDefault().post(new FirstEvent("success"));
EventBus 3.0可能出现异常
FATAL EXCEPTION: main
Process: com.hank.rxjavademo, PID: 6329
org.greenrobot.eventbus.EventBusException: Subscriber class com.hank.fragment.map.MapFragment and its super classes have no public methods with the @Subscribe annotation
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:67)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:136)
at com.hank.fragment.map.MapFragment.onCreateView(MapFragment.java:34)
解决方案:
在重写的event方法前加注解 @Subscribe
@Subscribe public void onEventMainThread(FirstEvent event){ eventBusButton.setText(event.getMsg()); }
相关文章推荐
- EventBus使用过程中,遇到的问题点
- 使用EventBus遇到的一个问题
- 初步使用EventBus时所遇到的一些问题
- 在win2003server上使用移动硬盘时遇到的问题以及禁用“关闭事件跟踪程序”
- 在IIS 6 中使用HTTP压缩(Compression)遇到的一个问题
- 在nhibernate使用过程中遇到的几个问题。
- 在nhibernate使用过程中遇到的几个问题02
- 在MIDAS中使用SocketConnection遇到的问题
- 关于您提到使用WebServices时候遇到“基础连接以关闭”的问题
- 求解在SQL中使用了where列所遇到的问题
- 使用Data Access Application Block遇到的问题
- VC6使用过程中遇到的问题收集(1) zz
- 刚才遇到了关于C#使用外部DLL函数上的char*的问题。
- updater application block v2.0的使用过程中遇到的问题及解决办法
- 使用css expression遇到的一个问题
- 使用Access存储Session,遇到了SessionId问题?
- 遇到 Web Server 中不能使用 XmlSerializer 的问题
- 使用SqlParameter参数返回值时遇到的问题
- 使用vs.net遇到的问题
- 使用logic:iterate遇到的问题