Open guyuecai opened 4 years ago
现在问题解决了吗?感觉配置没有什么问题
还是老样子 没有解决
在 2020-04-01 08:07:26,"Jeremy Liao" notifications@github.com 写道:
现在问题解决了吗?感觉配置没有什么问题
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
请升级到版本1.6.1,使用控制台辅助类Console获取LiveEventBus的内部信息,方便排查问题在哪
依赖 implementation 'com.jeremyliao:live-event-bus-x:1.5.7' Application的配置() {
@Override
public void onChanged(@Nullable String s) {
Log.e("****",s);
}
});
LiveEventBus.config(). supportBroadcast(this).lifecycleObserverAlwaysActive(true).autoClear(false); Mainactivity类,配置发送消息:LiveEventBus.get("key").post(“测试”); 另外一个类接收消息: LiveEventBus.get("key",String.class).observe(this, new Observer
我看了其他的回答好像是要用observeSticky。我就把上面的代码改一下。
主类(就一个onCreate方法,都市实例化控件): LiveEventBus.get("key",String.class).observeSticky(val);//不知道怎么写了(LifecycleOwner,Observer)
另外一个类接收消息:
LiveEventBus
.get("sticky_key", String.class)
.observeSticky(this, new Observer() {
@Override
public void onChanged(@Nullable String s){
Log.e("****",s);
}
});
麻烦大佬帮我看下怎么写主类(LifecycleOwner,Observer),还有配置对不对。谢谢。