title: Passing Parcelable item between activities
body: <p>I'm having trouble passing an object via an <code>Intent</code>. I keep getting a null pointer error. here it is:</p>
  
  <p>In my ListActivity:</p>
  
  <pre><code>@Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
      Intent intent = new Intent(MyListActivity.this, DetailsActivity.class);
      intent.putExtra("this_item", my_array.get(position));
      startActivity(intent);
  }
  </code></pre>
  
  <p>In the onCreate() of the DetailsActivity class:</p>
  
  <pre><code>thisItem = (MyObject) getIntent().getExtras().getParcelable("this_item");
  System.err.println(thisItem.getDescription()); //&lt;--Null pointer error!
  </code></pre>
  
  <p>The <code>MyObject</code> class does implement <code>Parcelable</code>. Why can't I pass this object over? I'm confused. Thanks for any help.</p>
  
  <p>EDIT: Here is that class:</p>
  
  <pre><code>public class MyObject implements Comparable&lt;MyObject&gt;, Parcelable {
  
      private Date date;
      private MyType my_type;
      private String description;
      private int flags;
  
      public MyObject(Date date, MyType type, String desc) {
          this.date = date;
          this.my_type = type;
          this.description = desc;
      }
  
      public Date getDate() {return date;}
      public MyType getMyType() {return my_type;}
      public String getDescription() {return description;}
  
      public int compareTo(MyObject another) {
          if (getDate() == null || another.getDate() == null) {return 0;}
          return getDate().compareTo(another.getDate());
      }
  
      public int describeContents() {
          return 0;
      }
  
      public void writeToParcel(Parcel dest, int flags) {
          dest.writeInt(flags);
      }   
  
      public static final Parcelable.Creator&lt;MyObject&gt; CREATOR = new Parcelable.Creator&lt;MyObject&gt;() {
          public MyObject createFromParcel(Parcel in) {
              return new MyObject(in);
          }
  
          public MyObject[] newArray(int size) {
              return new MyObject[size];
          }
      };
  
      private MyObject (Parcel in) {
          flags = in.readInt();
      }
  }
  </code></pre>