解决android EventBus 注册事件后但还无法相应事件的问题

 
这里只是我遇到的问题,请大家的问题"对号入座"
 
问题:
acitivity里的onstart注册事件EventBus.getDefault().register(this);service里有个子线程里post了一个xxxEvent实例,在activity里使用了public void onEventMainThread(xxxEvent event){}
问题来了,都是按照官网的介绍来使用的,就是响应不了事件.
运行时,logcat里有以下警告信息:
No subscribers registered for event class xxxEvent
No subscribers registered for event class de.greenrobot.event.NoSubscriberEvent
 
怎么会没有注册事件呢?明明有注册的啊!
查了好久,好久,原来
我这个service在manifest里注册是有个这些东西
android:name=".utils.service.SocketClientService"
android:exported="false"
android:process="system" />
 
改成:
android:name=".utils.service.SocketClientService" />
 
问题就解决了;
 
主要还是 android:process="system"问题造成的,算不算bug?

转载于:https://www.cnblogs.com/enyusmile/p/4442140.html

你可能感兴趣的:(移动开发)