How to send event from Service to Activity with Otto event bus?

后端 未结 7 1751
心在旅途
心在旅途 2020-12-02 05:19

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

7条回答
  •  遥遥无期
    2020-12-02 06:06

    I did it simply:

    Handler handler = new Handler(Looper.getMainLooper());
            handler.post(new Runnable() {
                @Override
                public void run() {
                    bus.post(event);
                }
    
            });
    

    Happy coding.. :)

提交回复
热议问题