Mr.Moayed Mr.Moayed - 1 year ago 42
JSON Question

How to pass array list between activities

I have this array list and i parsing list item from json like this ,

List<String> imageUrls;

imageUrls = new ArrayList<>();

JSONArray imageArray = response.getJSONObject(feedKey).getJSONArray(entryKey).getJSONObject(i).getJSONArray(imageKey);

for (int j = 0; j < imageArray.length(); j++) {
String imageList = imageArray.getJSONObject(j).getString(labelKey).toString();

then i try to do this in another activity ,

intent.putStringArrayListExtra("list", appShowModule.getAllimage());

but "appShowModule.getAllimage()" is error ! and how i can received it ?

Answer Source

Send your list like this

    Intent i = new Intent(this, YourDesiredActiity.class);

And then in your desired activity , receive the list like this

   ArrayList<String> urlList = new ArrayList<String>();
    Bundle extras = getIntent().getExtras();
    if (extras != null) {

Then you can get your desired arrayList in "urlList"