0

I am trying to pass an ArrayList<ArrayList<LatLng>> from one intent to another using putParcelableArrayListExtra () but for some reason it doesn't like my list. I define the array list with ArrayList<ArrayList<LatLng>> listOfStrokes = new ArrayList<>(); and I am trying to pass it with

ArrayList<ArrayList<LatLng>> listOfStrokes = new ArrayList<>();

Intent intent = new Intent(this, CreateFarm.class);

intent.putParcelableArrayListExtra("listOfStrokes", listOfStrokes);

but I am getting a

Error:(383, 65) error: incompatible types: ArrayList> cannot be converted to ArrayList

error. Is there a way to pass this object?

Ryan Newman
  • 846
  • 3
  • 17
  • 35

1 Answers1

0

First - consider using Guava tables to avoid a List of Lists pattern.

putParcelableArrayListExtra expects a List of objects that implements Parcelable. ArrayList does not. Arraylist implements Serializable, so the below will work.

ArrayList<ArrayList<LatLng>> listOfStrokes = new ArrayList<>();

Intent intent = new Intent(this, CreateFarm.class);

intent.putExtra("listOfStrokes", listOfStrokes);
bsautner
  • 4,479
  • 1
  • 36
  • 50