I'm using jsoup to parse a html code, I'm using obviously an AsyncTask but it's returning null (javanullpointerexception).
private class LoadDocument extends AsyncTask<String, Void, Document>
{
ProgressDialog mProgressDialog;
@Override
protected void onPreExecute() {
mProgressDialog = ProgressDialog.show(Parser.this, "Loading...", "Recuperation donnees...");
}
@Override
protected Document doInBackground(String... url) {
url[0] = urll;
try {
document = Jsoup.connect(url[0])
.data("query", "Java")
.userAgent("Mozilla")
.cookie("auth", "token")
.timeout(10000)
.post();
} catch (IOException e) {
e.printStackTrace();
}
return document;
}
@Override
protected void onPostExecute(Document result) {
document=result;
mProgressDialog.dismiss();
}
}
And then to execute a task and return the document:
urll= //the website
document=new LoadDocument().execute(urll).get();
I guess that document is always null. What's going wrong in my code? Thank you for helping.