title: How to use Android's AsyncTask to get all of my data through JSoup, then send that information to another class?
body: <p>I'm pretty new to developing in Android, but I understand that I cannot run <code>Jsoup.connect(url).get()</code> without some kind of thread as it is a synchronous call. I tried creating a class called Product that extends AsyncTask, and then having my original class called List call Product and then have the int displayed. However, regardless of the actual result, it always prints out 0.</p>
  
  <p>I have tested my code before, so I know it works and that the issue must be something related to Android.</p>
  
  <p>List Class:</p>
  
  <pre><code>public class List extends AppCompatActivity{
  String itemURL;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_item_list_view);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
        Bundle itemData = getIntent().getExtras();
      if(itemData==null){
          return;
      }
  
      //Gets URL
      itemURL = itemData.getString("itemURL");
      int listSize=new Product(itemURL).getListSize();
      System.out.println(listSize);
   }
  }
  </code></pre>
  
  <p>Product class:</p>
  
  <pre><code> public class Product extends AsyncTask&lt;Void,Void,Void&gt;{
      String url;
      String title;
      int listSize;
  
  
      public Product(String url){
          this.url = url;
      }
      protected Void doInBackground (Void... voids) {
         //Create JSoup connection
          try{
  
              Document doc = Jsoup.connect("url").get();
              //Gets title
              String link = doc.select("h2#s-result-count").first().text();
              System.out.println(link);
              listSize=Integer.parseInt(link.substring(0,1));
              System.out.println(listSize);
              try{
                  int listSize= Integer.parseInt(link.substring(0,2));
                  System.out.println(listSize);
                 }catch(Exception e){}
           }catch (Exception e){}
      }
  
  
        protected void onPostExecute(Void aVoid) {
              super.onPostExecute(aVoid);
              getListSize();
  
  
          }
  
         public int getListSize(){
          return listSize;
       }
  }
  </code></pre>
  
  <p>All advice would be appreciated, thanks for your time and help!</p>