Android:android.view.ViewRoot$CalledFromWrongThreadException - How to solve the problem?

前端 未结 3 499

An application I am currently developing is communicating with the server and the communication process runs in its own thread. There are asynchronous calls - for example lo

3条回答
  •  误落风尘
    2020-12-06 14:34

    Try Handler.

    Is onLoginResponse() is a callback function?
    If it is, the problem can be solved by Handler.

    In onLoginResponse(),

    hRefresh.sendEmptyMessage(REFRESH);
    
    
        Handler hRefresh = new Handler(){
        @Override
        public void handleMessage(Message msg) {
        switch(msg.what){
             case REFRESH:
                    /*Refresh UI*/
                    updateGUIState();
                    break;
           }
        }
    };
    

提交回复
热议问题