title: Serializable parcelable issue: RuntimeException: Parcelable encountered IOException writing serializable object
body: <p>Folks, I have simplest class which I want to be Parcelable. I'm doing it in following way:</p>
  
  <pre><code>public class MyField implements Serializable, Parcelable
  {
  
      public MyField()
      {
      }
  
  
      //************************************************
      // Parcelable methods
      //************************************************
      public int describeContents() {return 0; };
  
      public void writeToParcel(Parcel out, int flags)
      {
          out.writeInt(this.describeContents());
          out.writeSerializable(this);
      }
  
      @SuppressWarnings("redundant")       
      public Parcelable.Creator&lt;MyField&gt; CREATOR
              = new Parcelable.Creator&lt;MyField&gt;()
      {
          public MyField createFromParcel(Parcel in)
          {
              int description=in.readInt();
              Serializable s=in.readSerializable();
              switch(description)
              {
                  case 0:
                      return (MyField )s;
                  default:
                      return null;
              }
          }
  
          public MyField[] newArray(int size)
          {
              return new MyField[size];
          }
      };
  }
  </code></pre>
  
  <p>Simple, heh? Yes, looks like. But when I try to send my class object to another activity as parcel object like:</p>
  
  <pre><code>    intent=new Intent(activity, SendMessageActivity.class);
      MyField fld=new MyField();
      intent.putExtra("to", (Parcelable )fld);
      activity.startActivity(intent);
  </code></pre>
  
  <p>I'm getting following exception:</p>
  
  <pre><code>java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = ru.ivanovpv.android.storage.MyField)
  at android.os.Parcel.writeSerializable(Parcel.java:1131)
  at ru.ivanovpv.android.storage.MyField.writeToParcel(MyField.java:58)
  at android.os.Parcel.writeParcelable(Parcel.java:1106)
  at android.os.Parcel.writeValue(Parcel.java:1029)
  at android.os.Parcel.writeMapInternal(Parcel.java:469)
  at android.os.Bundle.writeToParcel(Bundle.java:1445)
  at android.os.Parcel.writeBundle(Parcel.java:483)
  at android.content.Intent.writeToParcel(Intent.java:5237)
  at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1204)
  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
  at android.app.Activity.startActivityForResult(Activity.java:2749)
  at android.app.Activity.startActivity(Activity.java:2855)
  at ru.ivanovpv.android.storage.BulkContact.doContextItemSelected(BulkContact.java:105)
  at ru.ivanovpv.android.cellmessenger.ContactsActivity.onContextItemSelected(ContactsActivity.java:188)
  at android.app.Activity.onMenuItemSelected(Activity.java:2174)
  at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2731)
  at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:139)
  at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
  at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:129)
  at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:884)
  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
  at android.widget.ListView.performItemClick(ListView.java:3285)
  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1640)
  at android.os.Handler.handleCallback(Handler.java:587)
  at android.os.Handler.dispatchMessage(Handler.java:92)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4363)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.io.NotSerializableException: ru.ivanovpv.android.storage.MyField$1
  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1547)
  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1854)
  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1696)
  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1660)
  at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1153)
  at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:420)
  at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1251)
  at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1587)
  at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1854)
  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1696)
  at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1660)
  at android.os.Parcel.writeSerializable(Parcel.java:1126)
  ... 31 more
  </code></pre>
  
  <p>Can't really understand what's here is unserializable?</p>