title: How to pass data from Async Class to Main Activity class
body: <p>I have JSON data that i converted into <code>JSONArray</code>. I have performed this conversion in an inner class which is extending <code>AsyncTask</code>. </p>
  
  <p>Now i have data which contains <code>Images</code> and their <code>Titles</code>. I want to create a Loop and create <code>ImageView</code> dynamically.</p>
  
  <p>The problem i am facing is that my data is in inner class and in <code>doInBackground()</code> method, and the stuff; i.e: <code>ImageView</code> i need to create is in Outer class and in <code>onCreate()</code> method.</p>
  
  <p>I am unable to understand how to use <code>jsonArray</code> which i created in my <code>InnerClass</code> in my outer class.</p>
  
  <p><strong>Inner Class:</strong> </p>
  
  <p>public class NewsService extends AsyncTask {</p>
  
  <pre><code>    @Override
      protected JSONArray doInBackground(String... params) {
  
          URL url = null;
          try {
            //All JSON to JSONArray conversion code goes here
            //..
  
            JSONArray jsonArray = new JSONArray(jsonString);
           return jsonArray; 
  </code></pre>
  
  <p><strong>Main Activity</strong> </p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          NewsService newsService = new NewsService();
          newsService.execute();
  
  //I need to use `jsonArray` in this part of my code
  </code></pre>