title: Parcelable inheritance in android caused ClassCastExeption
body: <p>i have a Parent class implementing parcelable and a child extending parent also implementing parcelable. My code is attached below. I get a runtime ClassCastException. What am I missing? 
  Thanks,</p>
  
  <p>Parent Class: </p>
  
  <pre><code>public class Follower implements Parcelable{
  
  private long id;
  private String fullName;
  
  public Follower() {
  
  }
  
  public Follower(String fullName) {
      this.fullName = fullName;
      }
  
  public long getId(){
      return id;
  }
  
  public void setId(long id) {
      this.id = id;
  }
  
  public String getFullName() {
      return fullName;
  }
  
  public void setFullName(String fullName) {
      this.fullName = fullName;
  }
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      dest.writeString(getFullName());
  
  }
  
  protected Follower(Parcel in){
      setFullName(in.readString());
  }
  
  public static final Parcelable.Creator&lt;Follower&gt; CREATOR =
          new Parcelable.Creator&lt;Follower&gt;() {
              public Follower createFromParcel(Parcel in) {
                  return new Follower(in);
              }
  
              public Teen[] newArray(int size) {
                  return new Teen[size];
              }
          };
  </code></pre>
  
  <p>}</p>
  
  <p>The Child Class</p>
  
  <pre><code>public class Teen extends Follower
                implements Parcelable{
  
  
  public Teen(){
      super();    
  }
  
  
  public Teen( String fullName, String birthDate) {
      super(fullName);
      this.birthDate = birthDate;
  }
  
  private String birthDate;
  
  public String getBirthDate() {
      return birthDate;
  }
  
  public void setBirthDate(String birthDate){
      this.birthDate = birthDate;
  }
  
  @Override
  public int describeContents() {
      return 0;
  }
  
  @Override
  public void writeToParcel(Parcel dest, int flags) {
      super.writeToParcel(dest, flags);
      dest.writeString (birthDate);
  }
  
  private Teen(Parcel in){
      super(in);  
      birthDate = in.readString();
  }
  
  public static final Parcelable.Creator&lt;Teen&gt; CREATOR =
          new Parcelable.Creator&lt;Teen&gt;() {
              public Teen createFromParcel(Parcel in) {
                  return new Teen(in);
              }
  
              public Teen[] newArray(int size) {
                  return new Teen[size];
              }
          };
  </code></pre>
  
  <p>}</p>
  
  <p>On the server, I create a Teen/Follower like below. The teen and follower clasess are copied to the server without the parcelable implementation.</p>
  
  <pre><code>public Follower getData()
  {
     if (logic to see if the user is a teen){
              Teen t = new Teen( "Full Name", "1:1:1960");
              return t;
    }
    else  
    {
        Follower f = new Follower("Full Name");
        return f;
    }
  }
  </code></pre>
  
  <p>On the client</p>
  
  <p>I do get the Follower in the client code. I have checked by accessing the Follower class methods. It works. However when I do something like this I get a ClassCastException at runtime.</p>
  
  <pre><code>    if(logic to see if it is a teen)
      {
          Teen t = (Teen) follower;
       }
  </code></pre>
  
  <p>I am sure it is something small that I am missing but am at loss. Any help will be appreciated. Thanks,</p>