i'm trying to do use a JSOUP HTML parsing library to get a HTML document using
Document doc = Jsoup.parse(u, 1000);
and i'm getting the error "android.os.NetworkOnMainThreadException"
I understand its because I need to have the download occurring somewhere other than the main thread but I don't understand how to fix this.
If I use threading I need to be able to return doc so I can parse through when the download is finished.
Can you help me fix this?
The class I am using is as follows:
public class DataSorter{
   private Document doc;
   DataSorter(){
      downloadData();
   }
   private void downloadData() throws IOException{
        String url = "www.google.com";
        URL u = new URL(url);
        System.out.println("Downloading....");
        doc = Jsoup.parse(u, 5000); //Time out 5000ms
        System.out.println("Download Successful");
   }
   Document getDoc(){
      return doc;
   }
}
 
     
     
     
    