I have two Activities, in the first one, I instanciate an ArrayList of Object myObject. In the second activity, i need to get this Arraylist. I\'ve found a tutorial : http:/
Hopefully, you've figured this out by now. But for anyone else who stumbles upon this one. The NullPointerException you were getting was caused by the ArrayList never being initialized.
This would fix it:
private Chapitre(){
listVideo = new ArrayList<Video>();
}
private Chapitre(Parcel source) {
// Call the above constructor
this();
numero = source.readInt();
titre = source.readString();
description = source.readString();
nbVideo = source.readInt();
source.readTypedList(listeVideo, Video.CREATOR);
}
Another solution: use createTypedArrayList
instead of readTypedList
which requires a non-null List object reference
Also consider initializing the object with an immutable empty list.
private ArrayList<Video> listevideo = Collections.emptyList()
More details here: Collections.emptyList() vs. new instance
Also keep in mind that you have to read and write parcelable object attribute in the same order! I also 2 hours because the unmarshalling was not in the same order of the marshalling.