I have a private List<Card> characters;
which contains Card
objects.
I need to pass it through an intent.
How do I do it? Tried putParcelableArrayListExtra()
but can't retrieve it or maybe I'm doing it in the wrong way, any ideas?
This is what I tried:
Intent intent = new Intent(this, RandomAssignment.class);
intent.putParcelableArrayListExtra("CHARACTERS", (ArrayList<? extends Parcelable>) characters);
startActivity(intent);
And to retrieve it:
characters = this.getIntent().getParcelableArrayListExtra("CHARACTERS");
EDIT:
I've implemented those 2 methods in the Card Class, but there are some other classes which extend Card. And I get this error on them:
Error:(7, 25) error: constructor Card in class Card cannot be applied to given types; required: Parcel found: no arguments reason: actual and formal argument lists differ in length
This is the code of one of the other classes which extend Card (they're very similar from one another):
public class Clairvoyant extends Card {
public Clairvoyant(){
this.setName("Clairvoyant");
}
public static boolean point(Card d){
return d.getClass() == Wolf.class;
}
}