Android : Calling the methods on UI thread from AsyncTask doInBackground method

前端 未结 4 1827
小鲜肉
小鲜肉 2020-12-03 05:30

I am using AsyncTask to upload data to UI. i wrote the code to download data from server in a separate method and i am calling that method from doinBackground. It will give

4条回答
  •  被撕碎了的回忆
    2020-12-03 05:56

    Use doInBackground() just for tasks that :

    1. Take some time
    2. Are not UI related

    Then you can implement AsyncTask.onPostExecute() to run code to handle those results on main UI thread from AsyncTask

    From JavaDoc for AsyncTask.onPostExecute():

    "Runs on the UI thread after doInBackground. ... "

提交回复
热议问题