title: Writing arrays of Parcelables to a Parcel in Android
body: <p>I'm trying to write an array of objects that implement <a href="http://developer.android.com/reference/android/os/Parcelable.html" rel="noreferrer">Parcelable</a> into a <a href="http://developer.android.com/reference/android/os/Parcel.html" rel="noreferrer">Parcel</a> using   <a href="http://developer.android.com/reference/android/os/Parcel.html#writeParcelableArray%28T%5B%5D,%20int%29" rel="noreferrer">writeParcelableArray</a>.</p>
  
  <p>The objects I'm trying to write are defined (as you'd expect) as:</p>
  
  <pre><code>public class Arrival implements Parcelable {
      /* All the right stuff in here... this class compiles and acts fine. */
  }
  </code></pre>
  
  <p>And I'm trying to write them into a `Parcel' with:</p>
  
  <pre><code>@Override
  public void writeToParcel(Parcel dest, int flags) {
      Arrival[] a;
      /* some stuff to populate "a" */
      dest.writeParcelableArray(a, 0);
  }
  </code></pre>
  
  <p>When Eclipse tries to compile this I get the error:</p>
  
  <blockquote>
    <p>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
    &lt; T extends Parcelable ></p>
  </blockquote>
  
  <p>I completely don't understand this error message. <code>Parcelable</code> is an interface (not a class) so you can't extend it. Anyone have any ideas?</p>
  
  <p><strong>UPDATE:</strong> I'm having basically the same problem when putting an <code>ArrayList</code> of <code>Parcelable</code>s into an <code>Intent</code>:</p>
  
  <pre><code>Intent i = new Intent();
  i.putParcelableArrayListExtra("locations", (ArrayList&lt;Location&gt;) locations);
  </code></pre>
  
  <p>yields:</p>
  
  <blockquote>
    <p>The method putParcelableArrayListExtra(String, ArrayList&lt; ? extends Parcelable >) in the type Intent is not applicable for the arguments (String, ArrayList&lt; Location >)</p>
  </blockquote>
  
  <p>This may be because <code>Location</code> was the class I was working on above (that wraps the <code>Arrival</code>s), but I don't think so.</p>