Nested Parcelling: RuntimeException - Unmarshalling unknown code type 3211319 at offset 440

I need to send some data to an Activity that may be running in a different context. To do this, I created a say A class that has an ArrayList data type that says B as its one of the members of the instance. I declared class B a class of class A Inner. To send an instance of class A through Intent , I made classes A and B as Parcelable .

The class structure is something like this (this does not include the complete code, for example code written to create Parcelable classes):

 public class A implements Parcelable{ public class B implements Parcelable{ public ArrayList<String> value; .... .... public void writeToParcel(Parcel dest, int flags) { dest.writeList(value); } .... .... } public List<B> group; public String name; .... .... public void writeToParcel(Parcel dest, int flags) { dest.writeList(group); dest.writeString(name); } .... .... } 

I used the putExtra (String name, Parcelable value) function to place the data.

But on the receiving side, I got the following exception:

  Uncaught handler: thread main exiting due to uncaught exception E/AndroidRuntime( 1087): 1289817569622 java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.SET_VOIP_SUPP_SERVICE_REQUEST_LOCAL (has extras) } in com.hsc.example.android.MyApp.MyAppActuvity$1@43b409b0 E/AndroidRuntime( 1087): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:765) E/AndroidRuntime( 1087): at android.os.Handler.handleCallback(Handler.java:587) E/AndroidRuntime( 1087): at android.os.Handler.dispatchMessage(Handler.java:92) E/AndroidRuntime( 1087): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 1087): at android.app.ActivityThread.main(ActivityThread.java:4363) E/AndroidRuntime( 1087): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 1087): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 1087): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) E/AndroidRuntime( 1087): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) E/AndroidRuntime( 1087): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 1087): Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@43b51240 : Unmarshalling unknown type code 3211319 at offset 440 E/AndroidRuntime( 1087): at android.os.Parcel.readValue(Parcel.java:1777) E/AndroidRuntime( 1087): at android.os.Parcel.readListInternal(Parcel.java:1956) E/AndroidRuntime( 1087): at android.os.Parcel.readList(Parcel.java:1302) E/AndroidRuntime( 1087): at com.hsc.example.android.MyApp.A.<init>(A.java:61) E/AndroidRuntime( 1087): at com.hsc.example.android.MyApp.A.<init>(A.java:57) E/AndroidRuntime( 1087): at com.hsc.example.android.MyApp.A$1.createFromParcel(A.java:67) E/AndroidRuntime( 1087): at com.hsc.example.android.MyApp.A$1.createFromParcel(A.java:1) E/AndroidRuntime( 1087): at android.os.Parcel.readParcelable(Parcel.java:1845) E/AndroidRuntime( 1087): at android.os.Parcel.readValue(Parcel.java:1713) E/AndroidRuntime( 1087): at android.os.Parcel.readMapInternal(Parcel.java:1947) E/AndroidRuntime( 1087): at android.os.Bundle.unparcel(Bundle.java:169) E/AndroidRuntime( 1087): at android.os.Bundle.getParcelable(Bundle.java:1037) E/AndroidRuntime( 1087): at android.content.Intent.getParcelableExtra(Intent.java:3269) E/AndroidRuntime( 1087): at com.hsc.example.android.MyApp.MyAppActuvity$1.onReceive(MyAppActuvity.java:219) E/AndroidRuntime( 1087): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:754) E/AndroidRuntime( 1087): ... 9 more 

Then I moved class B outside of class A (as I thought it could be an inner class problem and declared static by CREATOR. This static declaration was not if class B was an inner class of class A). But it did not help.

This problem seems to be related to the nested parcel.

Any suggestion

NOTE : when I used the android.os.Bundle.putParcelable(String key, Parcelable value) function of the Bundle class and then unmarshalled with android.os.Bundle.getParcelable(String key) , then everything is fine. It seems that the problem is only regarding intentions.

+6
android android-intent parcelable
source share
2 answers

Did you enable CREATOR for both?

 public static final Parcelable.Creator<A> CREATOR = new Parcelable.Creator<A>() { public A createFromParcel(Parcel in) { return new A(in); } public A[] newArray(int size) { return new A[size]; } }; 

& designers who accept the package:

 public A(Parcel parcel) { name = parcel.readString(); //etc.. } 

?

+1
source share
  • Change List<B> to ArrayList<B>
  • Use writeTypedList and readTypedList to write and read ArrayList
0
source share

All Articles