Pass list of objects from one activity to other activity in android

First, make the class of the list implement Serializable.

public class MyObject implements Serializable{}

Then you can just cast the list to (Serializable). Like so:

List<MyObject> list = new ArrayList<>();
myIntent.putExtra("LIST", (Serializable) list);

And to retrieve the list you do:

Intent i = getIntent();
list = (List<MyObject>) i.getSerializableExtra("LIST");

That’s it.

Leave a Comment