开发者

How do I download a Jsoup Document from a website asynchronously and then notify the UI thread when complete?

In my Android app, when a user clicks a button, I want it to execute this the below code asynchronously and and then somehow get the Document back to the UI t开发者_StackOverflowhread when it has completed executing. Ideally I'd like it to fire off an event on the UI thread so that I can do some operations on the document.

Document doc = Jsoup.connect(urls[0].toString()).get();

I'm really not sure the best way to go about this. I'm looking at an AsyncTask, but I can't figure out a clean way to get the Document back to the UI thread.

FYI, I am new to Java. I am mostly a .NET developer, and boy would I love to have a BackgroundWorker right about now.


Yes, AsyncTask is the right way, after download it, the UI thread will call your code.

 protected void onPostExecute(Long result) {
     showDialog("Download ok");
 }

see the document.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜