Android ASync task ProgressDialog isn't showing until background thread finishes

后端 未结 4 466
遇见更好的自我
遇见更好的自我 2020-12-01 14:37

I\'ve got an Android activity which grabs an RSS feed from a URL, and uses the SAX parser to stick each item from the XML into an array. This all works fine but, as expected

4条回答
  •  温柔的废话
    2020-12-01 15:09

    It is because you used AsyncTask.get() that blocks the UI thread "Waits if necessary for the computation to complete, and then retrieves its result.".

    The right way to do it is to pass Activity instance to your AsyncTask by constructor, and finish whatever you want to do in AsyncTask.onPostExecution().

提交回复
热议问题