title: Getting an Arraylist from an inner AsyncTask class
body: <p>I've parsed some <code>XML</code> Data in <code>Asynctask</code> and printed it in the log, but whenever I try to copy the <code>ArrayList</code> of data into my Activity, it always remains null.</p>
  
  <p>Here's the code,</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
     static ArrayList&lt;NewsItems&gt;myData=new ArrayList&lt;&gt;();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          ReadRss readRss = new ReadRss(this);
          readRss.execute();
         Log.d("TAG", String.valueOf(myData.size()));//This stays empty
      }
  
  
      public static void getData(ArrayList&lt;NewsItems&gt;items){
          for (int i=0; i&lt;items.size(); i++){
              myData.add(items.get(i));
          }
      }
      class ReadRss extends AsyncTask&lt;Void, Void, Void&gt;{
  
           ArrayList&lt;NewsItems&gt;feedItems = new ArrayList&lt;&gt;();
          Context context;
          String address = "http://www.thedailystar.net/frontpage/rss.xml";
          ProgressDialog progressDialog;
          URL url;
  
          public ReadRss(Context context) {
              this.context = context;
              progressDialog = new ProgressDialog(context);
              progressDialog.setMessage("Loading...");
          }
  
          @Override
          protected void onPreExecute() {
              if(progressDialog!=null){
                  if (!progressDialog.isShowing()){
                      progressDialog.show();
                  }
              }
              super.onPreExecute();
          }
  
          @Override
          protected void onPostExecute(Void aVoid) {
              super.onPostExecute(aVoid);
              if(progressDialog!=null){
                  if (progressDialog.isShowing()){
                      progressDialog.hide();
                  }
              }
              MainActivity.getData(feedItems);
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              ProcessXml(Getdata());
              return null;
          }
  
          private void ProcessXml(Document data) {
  
              if (data != null) {
  
                  Element root = data.getDocumentElement();
                  Node channel = root.getChildNodes().item(1);
                  NodeList items = channel.getChildNodes();
                  for (int i = 0; i &lt; items.getLength(); i++) {
                      Node currentchild = items.item(i);
                      if (currentchild.getNodeName().equalsIgnoreCase("item")) {
                          NewsItems item=new NewsItems();
                          NodeList itemchilds = currentchild.getChildNodes();
                          for (int j = 0; j &lt; itemchilds.getLength(); j++) {
                              Node current = itemchilds.item(j);
                              if (current.getNodeName().equalsIgnoreCase("title")){
                                  item.setTitle(current.getTextContent());
                              }else if (current.getNodeName().equalsIgnoreCase("description")){
                                  item.setDescription(current.getTextContent());
                              }else if (current.getNodeName().equalsIgnoreCase("media:thumbnail")){
                                  item.setMedia(current.getAttributes().getNamedItem("url").getTextContent());
                              }else if (current.getNodeName().equalsIgnoreCase("link")){
                                  item.setUrl(current.getTextContent());
                              }
                          }
                          feedItems.add(item);
                          Log.d("itemTitle", item.getTitle());
                          Log.d("itemDescription",item.getDescription());
                          Log.d("itemMediaLink",item.getMedia());
                          Log.d("itemLink",item.getUrl());
  
                      }
                  }
              }
  
          }
  
  
  
          public Document Getdata() {
              try {
                  url = new URL(address);
                  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                  connection.setRequestMethod("GET");
                  InputStream inputStream = connection.getInputStream();
                  DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
                  DocumentBuilder builder = builderFactory.newDocumentBuilder();
                  Document xmlDoc = builder.parse(inputStream);
                  return xmlDoc;
              } catch (Exception e) {
                  e.printStackTrace();
                  return null;
              }
          }
  
      }
  
  }
  </code></pre>
  
  <p>I tried calling a static method of the Activity in the <code>onPostExecute</code> method, it doesn't work.</p>