LiveEventBus icon indicating copy to clipboard operation
LiveEventBus copied to clipboard

activity之间跳转接收不到消息

Open guyuecai opened this issue 5 years ago • 3 comments

依赖 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<String>() { @Override public void onChanged(@Nullable String s) { Log.e("****",s); } });

我看了其他的回答好像是要用observeSticky。我就把上面的代码改一下。

主类(就一个onCreate方法,都市实例化控件): LiveEventBus.get("key",String.class).observeSticky(val);//不知道怎么写了(LifecycleOwner,Observer<T>) 另外一个类接收消息: LiveEventBus .get("sticky_key", String.class) .observeSticky(this, new Observer<String>() { @Override public void onChanged(@Nullable String s){ Log.e("****",s); } }); 麻烦大佬帮我看下怎么写主类(LifecycleOwner,Observer<T>),还有配置对不对。谢谢。

guyuecai avatar Mar 22 '20 03:03 guyuecai

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

JeremyLiao avatar Apr 01 '20 00:04 JeremyLiao

还是老样子 没有解决

在 2020-04-01 08:07:26,"Jeremy Liao" [email protected] 写道:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

guyuecai avatar Apr 05 '20 15:04 guyuecai

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

JeremyLiao avatar Apr 18 '20 01:04 JeremyLiao