I have a problem with getting website with jsoup on Android.
public class Parser
{
Parser()
{
new Parser1().execute();
}
class Parser1 extends AsyncTask<Void, Void, Void>
{
String website1 = "http://google.com";
Document doc;
@Override
protected void onPreExecute()
{
super.onPreExecute();
}
This code is not execute doInBackground method.
@Override
protected Void doInBackground(Void... params)
{
try
{
doc = Jsoup.connect(website1).get();
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
And the rest of code.
@Override
protected void onProgressUpdate(Void... values)
{
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(Void result)
{
Log.d ("OK",doc.toString());
super.onPostExecute(result);
}
@Override
protected void onCancelled()
{
super.onCancelled();
}
}
}
I tried to write code without class AsyncTask, but always on Json.connect the program was exception. Thanks for all replies.