JeremyLiao / LiveEventBus

:mailbox_with_mail:EventBus for Android,消息总线,基于LiveData,具有生命周期感知能力,支持Sticky,支持AndroidX,支持跨进程,支持跨APP
Apache License 2.0
3.87k stars 529 forks source link

activity之间跳转接收不到消息 #99

Open guyuecai opened 4 years ago

guyuecai commented 4 years ago

依赖 implementation 'com.jeremyliao:live-event-bus-x:1.5.7' Application的配置
LiveEventBus.config(). supportBroadcast(this).lifecycleObserverAlwaysActive(true).autoClear(false); Mainactivity类,配置发送消息:LiveEventBus.get("key").post(“测试”); 另外一个类接收消息: LiveEventBus.get("key",String.class).observe(this, new Observer() { @Override public void onChanged(@Nullable String s) { Log.e("****",s); } });

我看了其他的回答好像是要用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),还有配置对不对。谢谢。

JeremyLiao commented 4 years ago

现在问题解决了吗?感觉配置没有什么问题

guyuecai commented 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.

JeremyLiao commented 4 years ago

请升级到版本1.6.1,使用控制台辅助类Console获取LiveEventBus的内部信息,方便排查问题在哪