Parcelables. Why can\'t they be more easy? I\'m trying to write an application which sends an ArrayList as a parcelable. When I try to get the Intent in the second Activity,
You need to read from the Parcel
in the same order in which you wrote things. You are writing this.id
first, but you are attempting to read the string array before reading the id. Reverse the order of the calls in either the constructor or writeToParcel
.
Also, instead of writing a string array, why not just write each string individually? Seems a lot simpler.
public NewsItem(Parcel in) {
in.readInt();
this.name = in.readString();
this.bubble = in.readString();
this.drawable = in.readString();
this.title = in.readString();
this.summary = in.readString();
this.description = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.id);
dest.writeString(this.name);
dest.writeString(this.bubble);
dest.writeString(this.drawable);
dest.writeString(this.title);
dest.writeString(this.summary);
dest.writeString(this.description);
}