I have a problem with Parcelable Data in an ArrayList sending two actions using Android.Bundle
I have two operations (A and B).
In class Aaa.class:
ArrayList<Model> mModelList = new ArrayList<Model> //Fill ArrayList with a few Model-Objects Bundle mBundle = new Bundle; Intent mIntent = new Intent(Aaaa.this, Bbbb.class); mBundle.putParcelableArrayList("models", mModelList); mIntent.putExtras(mBundle); startActivity(mIntent);
In Bbbb.class:
Bundle mBundle = getIntent().getExtras(); ArrayList<Model> = mBundle.getParcelableArrayList("models");
Model.class implements Parcelable.
So the problem. When I populate an ArrayList (in Aaa.class) and put it in a Bundle, I see that the Bundle contains varios objects from the list. When I then try to populate the list in Bbbb.class, an exception is thrown.
ERROR/AndroidRuntime(11109): FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{test/test.activities.Bbbb}: java.lang.RuntimeException: Parcel android.os.Parcel@405585d0 : Unmarshalling unknown type code 7667810 at offset 144 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667) at android.app.ActivityThread.access$1500(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@405585d0 : Unmarshalling unknown type code 7667810 at offset 144 at android.os.Parcel.readValue(Parcel.java:1913) at android.os.Parcel.readListInternal(Parcel.java:2092) at android.os.Parcel.readArrayList(Parcel.java:1536) at android.os.Parcel.readValue(Parcel.java:1867) at android.os.Parcel.readMapInternal(Parcel.java:2083) at android.os.Bundle.unparcel(Bundle.java:208) at android.os.Bundle.getParcelableArrayList(Bundle.java:1144) at test.activities.Bbbb.onCreate(Bbbb.java:52) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) ... 11 more
Line52 -
ArrayList<Model> = mBundle.getParcelableArrayList("models");
I have absolutely no idea where the problem is here, Model.class works fine with other Bundle - Intents.
Update:
The next class of model.
public class Model implements Parceleble{ private String name; private String address; public Model(Parcel parcel){ } public Model(){ } public Model(String name, String address){ this.name = name; this.address = address; }
Chris source share