How to send event from Service to Activity with Ot

2019-01-10 02:10发布

Simple BusProvider.getInstance().post() bring exception not main thread. How to send event from Service to Activity with Otto event bus?

标签: android otto
7条回答
混吃等死
2楼-- · 2019-01-10 02:47

Or simply do this if you're sure that you're posting from a Non-main thread:

new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        mBus.post(new myEvent());
                    }
                });

Just as the saying goes, "Keep It Simple and Stupid" :)

查看更多
登录 后发表回答