Is putSerializable broken?
When I pass null with putSerializable the FillSummary.class starts as it should. If I however pass the a TestSerial object than Android force closes.
What do I have to do to get a custom object transfered via a Bundle?
public class TestSerial implements Serializable{
private static final long serialVersionUID = 2310640779687082782L;
public int i;
public TestSerial(){
i=1;
}
}
private void renderSummary(){
Intent intent = new Intent(FillForm.this, FillSummary.class);
Bundle extras = new Bundle();
extras.putSerializable("test serial", new TestSerial());
intent.putExtras(extras);
startActivityForResult(intent, Forms.DISPLAY_SUMMARY);
}
Error:
06-28 13:56:02.436: ERROR/AndroidRuntime(1136): Uncaught handler: thread main exiting due to uncaught exception
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { action=Return user choice (has extras) }} to activity {com.Questionaire/com.Questionaire.FillForm}: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.Questionaire.FillForm$TestSerial)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityThread.deliverResults(ActivityThread.java:3005)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3047)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityThread.access$2300(ActivityThread.java:112)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Handler.dispatchMessage(Handler.java:99)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Looper.loop(Looper.java:123)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityThread.main(ActivityThread.java:3948)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.lang.reflect.Method.invokeNative(Native Method)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.lang.reflect.Method.invoke(Method.java:521)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at dalvik.system.NativeStart.main(Native Method)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): Caused by: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.Questionaire.FillForm$TestSerial)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Parcel.writeSerializable(Parcel.java:1147)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Parcel.writeValue(Parcel.java:1101)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Parcel.writeMapInternal(Parcel.java:469)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Parcel.writeBundle(Parcel.java:491)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.content.Intent.writeToParcel(Intent.java:4471)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1036)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1449)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.Activity.startActivityForResult(Activity.java:2656)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at com.Questionaire.FillForm.renderSummary(FillForm.java:206)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at com.Questionaire.FillForm.renderNext(FillForm.java:178)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at com.Questionaire.FillForm.onActivityResult(FillForm.java:86)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.Activity.dispatchActivityResult(Activity.java:3595)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.app.ActivityThread.deliverResults(ActivityThread.java:3001)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): ... 11 more
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): Caused by: java.io.NotSerializableException: com.Questionaire.FillForm
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1753)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:2073)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1900)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1863)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1354)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:421)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1456)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1789)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:2073)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1900)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1863)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): at android.os.Parcel.writeSerializable(Parcel.java:1142)
06-28 13:56:02.784: ERROR/AndroidRuntime(1136): ... 23 more
TestSerial
should be either static or declared in a separate file so that it won't be dragging the enclosing non-serializable type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With