I need to get values from internet using AsyncTask and JSoup, I want to convert the scraped data from JSoup an make them into a String I can use later on my class to build a List. I was wondering if I can create a String from the JSoup result inside the AsyncTask and use it on an external class? I was thinking on something like this:
String url = "http://mysite.com.data.php";
public class Title extends AsyncTask<Void, Void, Void> {
String title;
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
try {
// Connect to the web site
Document document = Jsoup.connect(url).get();
// Get the html document title
title = document.title();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
String myString = title; //<---TAKE THIS STRING FROM HERE
}// |
}// V
String my2ndString = myString; //<---------AND USE IT HERE
I am java noob, can you please help me