aafonso1991 aafonso1991 - 10 months ago 54
Java Question

Implement Parcelable

I have my class Video which implements

. I'm having problems on my constructor, and what is giving me problems is the variable mSource which is an
. I put an arrow on the line which is giving me problems.

public class Video implements Parcelable {
public URI mThumb;
public ArrayList<URI> mSource;
public String mTitle;
public String mSubTitle;
public String mDescription;

public Video(final URI thumb, final URI source, final String title, final String subtitle,
final String description) {
this.mThumb = thumb;
this.mSource = new ArrayList<URI>(1);
this.mTitle = title;
this.mSubTitle = subtitle;
this.mDescription = description;

public Bundle getAsBundle() {
Bundle b = new Bundle();
b.putString("title", mTitle);
b.putString("subtitle", mSubTitle);
b.putString("description", mDescription);
b.putString("thumb", mThumb.toString());
b.putString("source", mSource.get(0).toString());
return b;

public int describeContents() {
// TODO Auto-generated method stub
return 0;

public void writeToParcel(Parcel out, int arg1) {
// TODO Auto-generated method stub

public static final Parcelable.Creator<Video> CREATOR = new Parcelable.Creator<Video>() {
public Video createFromParcel(Parcel in) {
return new Video(in);

public Video[] newArray(int size) {
return new Video[size];

private Video(Parcel in) {
mTitle = in.readString();
mSubTitle = in.readString();
mDescription = in.readString();
mThumb = new URI(in.readString());
mSource = new ArrayList<URI>();
in.readTypedList(mSource, Video.CREATOR); //<----THIS LINE RIGHT HERE.


I have tried readList, readTypedList but I keep getting the error saying that it's not applicable for the arguments(..); Any suggestions?


out.writeString means you can't use in.readTypedList to read it back, you need to use in.readString()