OkHTTP Update UI from enqueue callback

前端 未结 4 1967
醉话见心
醉话见心 2020-12-31 09:41

I am trying to use OkHTTP library. When making a call to the server and getting a successful response back. i need to update the UI.

How can this be done when doing

4条回答
  •  渐次进展
    2020-12-31 10:25

    Try this:

    Handler mainHandler = new Handler(Looper.getMainLooper());
    mainHandler.post(new Runnable() {
        @Override
        public void run() {
            // code to interact with UI
        }
    });
    

提交回复
热议问题