解決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里注冊是有個這些東西
<service
android:name=".utils.service.SocketClientService"
android:exported="false"
android:process="system" />
 
改成:
<service
android:name=".utils.service.SocketClientService" />
 
問題就解決了;
 
主要還是 android:process="system"問題造成的,算不算bug?


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM