Waiting till the async task finish its work

前端 未结 5 455
说谎
说谎 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:17

    wait until this call is finish its executing

    You will need to call AsyncTask.get() method for getting result back and make wait until doInBackground execution is not complete. but this will freeze Main UI thread if you not call get method inside a Thread.

    To get result back in UI Thread start AsyncTask as :

    String str_result= new RunInBackGround().execute().get();
    

提交回复
热议问题