Intent intent = new Intent(getActivity(), loadactivity.class);
intent.putExtra("Arraylist", imagearraylist);
startActivity(intent)
Asked
Active
Viewed 329 times
0
-
do you have array list of string or object? – akshay_shahane Sep 26 '19 at 05:35
-
4Possible duplicate of [How to send data from fragment to another activity?](https://stackoverflow.com/questions/46954409/how-to-send-data-from-fragment-to-another-activity) – denvercoder9 Sep 26 '19 at 05:36
-
That is object arraylist – Taps Sep 26 '19 at 05:37
-
4Possible Dublicate Please Check The Links Below [Passing ArrayList From Activity To Fragment](https://stackoverflow.com/questions/39867847/android-passing-arraylistmodel-to-fragment-from-activity) – Vaithiya Nathan Sep 26 '19 at 05:38
-
I am not passing String data... I want to send arraylist – Taps Sep 26 '19 at 05:39
-
I want to pass from fragment to activity that is for passing arraylist to fragment @VaithiyaNathan – Taps Sep 26 '19 at 05:41
-
https://developer.android.com/reference/android/content/Intent.html#putParcelableArrayListExtra(java.lang.String,%20java.util.ArrayList%3C?%20extends%20android.os.Parcelable%3E) – denvercoder9 Sep 26 '19 at 05:59
-
https://stackoverflow.com/questions/15133121/pass-arraylist-implements-parcelable-to-activity – denvercoder9 Sep 26 '19 at 05:59
-
you should use a parcelable – Aram Sheroyan Sep 26 '19 at 07:18
3 Answers
0
Hope this will help you! Paste the following code in your activity.
ArrayList<Object> imagearraylist = (ArrayList<Object>) getIntent().getSerializableExtra("Arraylist");
Reference: How to pass ArrayList<CustomeObject> from one activity to another?

Hay Trần
- 564
- 4
- 22
0
Use Interface Like Mentioned In Link
Passing Data Between Fragments to Activity
Or You Can Simply Use Public static ArrayList<String> imagearraylist;
(Passing Huge Arraylist Through Intent May Leads To Crash)

Vaithiya Nathan
- 46
- 1
- 8
0
For this, you have to use interface
public interface arrayInterface {
public void onSetArray(ArrayList<T>);
}
Implement this interface in your activity
public class YrActivity extends Activity implements arrayInterface.OnFragmentInteractionListener {
private ArrayList<T> allData;
@override
public void arrayInterface(ArrayList<T> data) {
allData = data;
}
}
Then you have to send the data with listner
arrayInterface listener = (arrayInterface) activity;
listener.onSetArray(allData)
And its done

Shivam Sharma
- 96
- 5