title: Serializable and interfaces: Parcelable encountered IOException writing serializable object
body: <p>I have read various threads related to this topic on stackoverflow but none seem to address this particular problem I have.</p>
  
  <p>I use the following object as a interface:</p>
  
  <pre><code>public class FailGroupCreateEvent implements Serializable {
  
      private OnEventListener mOnEventListener;
  
      public void setOnEventListener(OnEventListener listener) {
          mOnEventListener = listener;
      }
  
      public void doEvent() {
          if (mOnEventListener != null) {
              mOnEventListener.onEvent(); // event object :)
          }
      }
  
      public interface OnEventListener extends Serializable {
          void onEvent();
      }
  
  }
  </code></pre>
  
  <p>It is there so that if a group fails to get created <code>Activity B</code>, it will notify <code>Activity A</code> and <code>Activity A</code> will load a snackbar to show a failure message.</p>
  
  <p>In <code>Activity A</code>, I do the following:</p>
  
  <pre><code>FailGroupCreateEvent failGroupCreateEvent = new FailGroupCreateEvent();
  
  FailGroupCreateEvent.OnEventListener failedToCreateGroup = new FailGroupCreateEvent.OnEventListener() {
      @Override
      public void onEvent() {
          Snackbar.make(getView(), getString(R.string.failed_group_create), Snackbar.LENGTH_LONG).show();
      }
  };
      failGroupCreateEvent.setOnEventListener(failedToCreateGroup);
  </code></pre>
  
  <p>I then start <code>Activity B</code> using the following code and put the extra into the intent:</p>
  
  <pre><code>                Intent intent = new Intent(context, ActivityB.class);
                  intent.putExtra(context.getString(R.string.failed_intent), failGroupCreateEvent);
                  startActivity(intent);
  </code></pre>
  
  <p>In <code>ActivityB</code>, I do the following:</p>
  
  <pre><code>FailGroupCreateEvent failGroupCreateEvent;
  if (//there is some type of network error) {
        failGroupCreateEvent.doEvent();
  }
  </code></pre>
  
  <p>However, the FailGroupCreateEvent object is throwing this error:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.myapp, PID: 4720
                                                   java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.myapp.interfaces.FailGroupCreateEvent)
                                                       at android.os.Parcel.writeSerializable(Parcel.java:1394)
                                                       at android.os.Parcel.writeValue(Parcel.java:1341)
                                                       at android.os.Parcel.writeArrayMapInternal(Parcel.java:644)
                                                       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313)
                                                       at android.os.Bundle.writeToParcel(Bundle.java:1034)
                                                       at android.os.Parcel.writeBundle(Parcel.java:669)
                                                       at android.content.Intent.writeToParcel(Intent.java:7485)
                                                       at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2411)
                                                       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1496)
                                                       at android.app.Activity.startActivityForResult(Activity.java:3745)
                                                       at android.app.Activity.startActivityForResult(Activity.java:3706)
                                                       at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:843)
                                                       at android.app.Activity.startActivity(Activity.java:4016)
                                                       at android.app.Activity.startActivity(Activity.java:3984)
                                                       at com.adapter.InnerPlaceAdapter$1.onClick(InnerPlaceAdapter.java:282)
                                                       at android.view.View.performClick(View.java:4780)
                                                       at android.view.View$PerformClick.run(View.java:19866)
                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                       at android.os.Looper.loop(Looper.java:135)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                    Caused by: java.io.NotSerializableException: com.myapp.activities.PlacesFragment
                                                       at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344)
                                                       at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                       at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                       at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                       at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                       at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                       at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                       at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                       at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                       at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                       at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                       at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                       at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959)
                                                       at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360)
                                                       at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054)
                                                       at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384)
                                                       at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
                                                       at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
                                                       at android.os.Parcel.writeSerializable(Parcel.java:1389)
                                                       at android.os.Parcel.writeValue(Parcel.java:1341) 
                                                       at android.os.Parcel.writeArrayMapInternal(Parcel.java:644) 
                                                       at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1313) 
                                                       at android.os.Bundle.writeToParcel(Bundle.java:1034) 
                                                       at android.os.Parcel.writeBundle(Parcel.java:669) 
                                                       at android.content.Intent.writeToParcel(Intent.java:7485) 
                                                       at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2411) 
                                                       at android.app.Instrumentation.execStartActivity(Instrumentation.java:1496) 
                                                       at android.app.Activity.startActivityForResult(Activity.java:3745) 
                                                       at android.app.Activity.startActivityForResult(Activity.java:3706) 
                                                       at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:843) 
                                                       at android.app.Activity.startActivity(Activity.java:4016) 
                                                       at android.app.Activity.startActivity(Activity.java:3984) 
                                                       at com.adapter.InnerPlaceAdapter$1.onClick(InnerPlaceAdapter.java:282) 
                                                       at android.view.View.performClick(View.java:4780) 
                                                       at android.view.View$PerformClick.run(View.java:19866) 
                                                       at android.os.Handler.handleCallback(Handler.java:739) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:95) 
                                                       at android.os.Looper.loop(Looper.java:135) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at java.lang.reflect.Method.invoke(Method.java:372) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
  </code></pre>
  
  <p>Why can I not pass this as a serializable object between the two activities?</p>