Waiting till the async task finish its work

前端 未结 5 454
说谎
说谎 2020-11-28 21:39

I\'m very new to programming and I have some doubts.

I have a AsyncTask which is I call as RunInBackGround.

and I start this proc

5条回答
  •  悲&欢浪女
    2020-11-28 22:13

    I think the easiest way is to create an interface to get the data from onpostexecute and run the Ui from interface :

    Create an Interface :

    public interface AsyncResponse {
        void processFinish(String output);
    }
    

    Then in asynctask

    @Override
    protected void onPostExecute(String data) {
        delegate.processFinish(data);
    }
    

    Then in yout main activity

    @Override
    public void processFinish(String data) {
         // do things
    
    }
    

提交回复
热议问题