1

In my Parcelable class, inside the writeToParcel method, I get this error:

Inferred type 'MyObject' for type parameter 'T' is not within its bound; should 
implement 'android.os.Parcelable

when I try to write an ArrayList, by this way:

dest.writeTypedList(new ArrayList<MyObject>());

In my code I can write strings by dest.writeString, but when I try to write this Array of MyObject I get the above mentioned error.

How can I fix this?

What is the best way to write an ArrayList to a Parcel object?

Thank you!

androidevil
  • 9,011
  • 14
  • 41
  • 79

2 Answers2

0

As @devconsole pointed out, your class MyObject is required to implement 'android.os.Parcelable', pretty much what the error message says.

You can find an example here:

How can I make my custom objects Parcelable?

Community
  • 1
  • 1
bgse
  • 8,237
  • 2
  • 37
  • 39
  • hi @bgse the message is that in my question: Inferred type 'MyObject' for type parameter 'T' is not within its bound; should implement 'android.os.Parcelable – androidevil Nov 13 '13 at 20:02
0

Go to your "MyObject" class and make sure it implements Parcelable, you shall see the error gone

ts772890
  • 1
  • 1