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 thread 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.
see the document.