Skip to content Skip to sidebar Skip to footer

How To Pass An Arraylist To The Startactivityforresult Activity

I need to from Activity A start an Activity B for result. I need to pass a String ArrayList from Activity A to Activity B first. I thought that this code would work but it crashes

Solution 1:

Replace:

Intentintent=newIntent(MainActivity.this,PopUpRunda.class);
BundlesendList=newBundle();
sendList.putStringArrayList("list",listA);
startActivityForResult(intent,2,sendList);

with:

Intent intent = newIntent(MainActivity.this,PopUpRunda.class);
intent.putStringArrayListExtra("list",listA);
startActivityForResult(intent,2);

The Bundle that is available as a parameter on startActivityForResult() is not how you pass Intent extras.

Post a Comment for "How To Pass An Arraylist To The Startactivityforresult Activity"