I have JSON data that i converted into JSONArray. I have performed this conversion in an inner class which is extending AsyncTask.
Now i have data which contains Images and their Titles. I want to create a Loop and create ImageView dynamically.
The problem i am facing is that my data is in inner class and in doInBackground() method, and the stuff; i.e: ImageView i need to create is in Outer class and in onCreate() method.
I am unable to understand how to use jsonArray which i created in my InnerClass in my outer class.
Inner Class:
public class NewsService extends AsyncTask {
@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;
Main Activity
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