1

I want to store ArrayList<ArrayList<Transports>> arrayListsTransportsForAllStops between activities. Class Transport implements Parcelable. But when i try to make

intent.putParcelableArrayListExtra("transports",arrayListsTransportsForAllStops);

My environmrnt get error:

enter image description here

And how to get this data back from intent?

Community
  • 1
  • 1
Kostya Khuta
  • 1,846
  • 6
  • 26
  • 48

2 Answers2

1

If you want put parcelable to intent just add:

intent.putParcelableArrayListExtra("transports", (ArrayList<? extends Parcelable>) arrayListsTransportsForAllStops);

To get this in next activity:

Intent data = getIntent();
List <Transports> result = data.getParcelableArrayListExtra("transports");
buxik
  • 2,583
  • 24
  • 31
1

You can iterate through ArrayList<Transports> objects in its enclosing ArrayList and for each of this ArrayList<Transports> objects you should use putParcelableArrayListExtra separately using different keys for each of them.

Tiko
  • 990
  • 7
  • 18
  • Well the API is leaving you with no choice. Consider what your goal is and make your mind up whether you should do this way. – Tiko Aug 02 '14 at 11:38