Android为TV端助力 EventBus出现has no public methods called onEvent的问题

时间:2023-12-10 11:13:38

Caused by: de.greenrobot.event.EventBusException: Subscriber class com.hhzt.iptv.lvb_w.socket.MyMsgService has no public methods called onEvent

Android为TV端助力 EventBus出现has no public methods called onEvent的问题

出现上述的问题原因就是你在当前类中去注册EventBus.getDefault().register(this),但是你并没有在当前类中写任何关于onEvent开头的公共的方法,所以报错

意思就是,如果你要在哪个类中接收EventBus消息,那你才去注册EventBus.getDefault().register(this),并且复写一个onEvent开头的公共的方法,如果你仅仅是

单纯的发送消息EventBus.getDefault().post(bean); 是不需要注册的,我之前报错就是误以为,发送消息也要注册,所以。。。

另外需求注意的是EventBus.getDefault().post(bean)发送消息给activity,如果当前的接收消息的activity不处于前台任务栈,那么是无法收到消息的