2

当我尝试RestaurantModel restaurant = getIntent().getParcelableExtra("restaurant");

哪个电话(第二个包裹类)in.readList(unitModels, UnitModel.class.getClassLoader());

然后它在in.readList(deliveryModels, DeliveryModel.class.getClassLoader());(3rd parcelable class)内崩溃

protected RestaurantModel(Parcel in) {
    description = in.readString();
    id = in.readInt();
    logo = in.readString();
    photo = (Bitmap) in.readValue(Bitmap.class.getClassLoader());
    name = in.readString();
    if (in.readByte() == 0x01) {
        unitModels = new ArrayList<UnitModel>();
        in.readList(unitModels, UnitModel.class.getClassLoader());
    } else {
        unitModels = null;
    }
    website = in.readString();
}

protected UnitModel(Parcel in) {
    address = in.readString();
    canDeliver = in.readByte() != 0x00;
    city = in.readString();
    if (in.readByte() == 0x01) {
        deliveryModels = new ArrayList<DeliveryModel>();
        in.readList(deliveryModels, DeliveryModel.class.getClassLoader());
    } else {
        deliveryModels = null;
    }
    id = in.readInt();
    networkID = in.readInt();
    phone = in.readString();
    if (in.readByte() == 0x01) {
        timeModels = new ArrayList<TimeModel>();
        in.readList(timeModels, TimeModel.class.getClassLoader());
    } else {
        timeModels = null;
    }
}

错误日志:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app/com.app.Restaurant.Restaurant}: java.lang.RuntimeException: Parcel android.os.Parcel@41c54770: Unmarshalling unknown type code 3801136 at offset 612
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
            at android.app.ActivityThread.access$800(ActivityThread.java:156)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5872)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1069)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@41c54770: Unmarshalling unknown type code 3801136 at offset 612
            at android.os.Parcel.readValue(Parcel.java:2089)
            at android.os.Parcel.readListInternal(Parcel.java:2352)
            at android.os.Parcel.readList(Parcel.java:1587)
            at com.app.Restaurant.UnitModel.<init>(UnitModel.java:56)
            at com.app.Restaurant.UnitModel$1.createFromParcel(UnitModel.java:13)
            at com.app.Restaurant.UnitModel$1.createFromParcel(UnitModel.java:10)
            at android.os.Parcel.readParcelable(Parcel.java:2113)
            at android.os.Parcel.readValue(Parcel.java:2022)
            at android.os.Parcel.readListInternal(Parcel.java:2352)
            at android.os.Parcel.readList(Parcel.java:1587)
            at com.app.Restaurant.RestaurantModel.<init>(RestaurantModel.java:47)
            at com.app.Restaurant.RestaurantModel$1.createFromParcel(RestaurantModel.java:14)
            at com.app.Restaurant.RestaurantModel$1.createFromParcel(RestaurantModel.java:11)
            at android.os.Parcel.readParcelable(Parcel.java:2113)
            at android.os.Parcel.readValue(Parcel.java:2022)
            at android.os.Parcel.readArrayMapInternal(Parcel.java:2323)
            at android.os.Bundle.unparcel(Bundle.java:249)
            at android.os.Bundle.getParcelable(Bundle.java:1206)
            at android.content.Intent.getParcelableExtra(Intent.java:5007)
            at com.app.Restaurant.Restaurant.onCreate(Restaurant.java:30)
4

0 回答 0