问题
How do I wrap a method around this Async section of codes so I can get the variable "doc" returned as a returned value so I can reuse this method? I can't declare a static method inside this class, and when I tried to use a void method, the variable "doc" can't be returned, and there's also errors in the code.
class JsoupParseTask extends AsyncTask<String, Void, Document> {
protected Document doInBackground(String... urls) {
Document doc = null;
try {
doc = Jsoup.connect("https://jsoup.org//").get();
}
catch (IOException e)
{
e.printStackTrace();
}
return doc;
}
}
回答1:
Use
protected void onPostExecute(Document
result) {
// Use here
}
来源:https://stackoverflow.com/questions/59605699/how-to-wrap-a-method-around-an-async-section-of-code