I'm trying to write an array of objects that implement Parcelable into a Parcel using writeParcelableArray.
The objects I'm trying to write are defined (as you'd expect) as:
public class Arrival implements Parcelable {
/* All the right stuff in here... this class compiles and acts fine. */
}
And I'm trying to write them into a `Parcel' with:
@Override
public void writeToParcel(Parcel dest, int flags) {
Arrival[] a;
/* some stuff to populate "a" */
dest.writeParcelableArray(a, 0);
}
When Eclipse tries to compile this I get the error:
Bound mismatch: The generic method writeParcelableArray(T[], int) of type Parcel is not applicable for the arguments (Arrival[], int). The inferred type Arrival is not a valid substitute for the bounded parameter < T extends Parcelable >
I completely don't understand this error message. Parcelable
is an interface (not a class) so you can't extend it. Anyone have any ideas?
UPDATE: I'm having basically the same problem when putting an ArrayList
of Parcelable
s into an Intent
:
Intent i = new Intent();
i.putParcelableArrayListExtra("locations", (ArrayList<Location>) locations);
yields:
The method putParcelableArrayListExtra(String, ArrayList< ? extends Parcelable >) in the type Intent is not applicable for the arguments (String, ArrayList< Location >)
This may be because Location
was the class I was working on above (that wraps the Arrival
s), but I don't think so.