Parcelable encountered IOException writing serializable object (name = xxx)
- java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = xxx)
- at android.os.Parcel.writeSerializable(Parcel.java:1160)
- at android.os.Parcel.writeValue(Parcel.java:1114)
- at android.os.Parcel.writeMapInternal(Parcel.java:479)
- at android.os.Bundle.writeToParcel(Bundle.java:1552)
- at android.os.Parcel.writeBundle(Parcel.java:493)
- at android.content.Intent.writeToParcel(Intent.java:5438)
- at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1288)
- at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
- at android.app.Activity.startActivityForResult(Activity.java:2817)
- at android.app.Activity.startActivity(Activity.java:2923)
- at android.widget.AdapterView.performItemClick(AdapterView.java:284)
- at android.widget.ListView.performItemClick(ListView.java:3382)
- at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
- 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:4627)
- 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:868)
- at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
- at dalvik.system.NativeStart.main(Native Method)
- Caused by: java.io.NotSerializableException: org.mdx.activity.collaboration.CollaborationListActivity
- at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1547)
- at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1859)
- at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1701)
- at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1665)
- 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:1859)
- at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1701)
- at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1665)
- at android.os.Parcel.writeSerializable(Parcel.java:1155)
activity之间传递自定义数据,需要implements Serializable或者Parcelable接口
可以用bundle putSerializable(String,Serizlizable)数据或者直接用intent putExtrr(String,Serizlizable)数据。
我有一个需求需要传递多个自定义类型数据,于是我写了一个数据类Value把我需要的那些自定义数据封装了起来,这个类实现了Serizlizable接口。但是在putExtra的时候出现了错误。
后来我发现要想在Activity之间传递数据必须所有的内容都实现serializable接口才行,而我的Value中封装的一个自定义类型数据没有实现这个接口,所以出现了错误。
之后我让那个自定义类型实现了serializable接口就没有问题了。