I have several classes that implement Parcelable , and some of these classes contain each other as properties. I collect classes in Parcel to pass them between actions. Marshalling them to the site works great, but when I try to untie them, I get the following error:
... AndroidRuntime E Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: schemas.Arrivals.LocationType AndroidRuntime E at android.os.Parcel.readParcelable(Parcel.java:1822) AndroidRuntime E at schemas.Arrivals.LayoverType.<init>(LayoverType.java:121) AndroidRuntime E at schemas.Arrivals.LayoverType.<init>(LayoverType.java:120) AndroidRuntime E at schemas.Arrivals.LayoverType$1.createFromParcel(LayoverType.java:112) AndroidRuntime E at schemas.Arrivals.LayoverType$1.createFromParcel(LayoverType.java:1) AndroidRuntime E at android.os.Parcel.readTypedList(Parcel.java:1509) AndroidRuntime E at schemas.Arrivals.BlockPositionType.<init>(BlockPositionType.java:244) AndroidRuntime E at schemas.Arrivals.BlockPositionType.<init>(BlockPositionType.java:242) AndroidRuntime E at schemas.Arrivals.BlockPositionType$1.createFromParcel(BlockPositionType.java:234) AndroidRuntime E at schemas.Arrivals.BlockPositionType$1.createFromParcel(BlockPositionType.java:1) ...
Class LayoverType (where it does not work):
public class LayoverType implements Parcelable { protected LocationType location; protected long start; protected long end; public LayoverType() {} public LocationType getLocation() { return location; } public void setLocation(LocationType value) { this.location = value; } public long getStart() { return start; } public void setStart(long value) { this.start = value; } public long getEnd() { return end; } public void setEnd(long value) { this.end = value; }
Here's the LocationType class:
public class LocationType implements Parcelable { protected int locid; protected String desc; protected String dir; protected double lat; protected double lng; public LocationType() {} public int getLocid() { return locid; } public void setLocid(int value) { this.locid = value; } public String getDesc() { return desc; } public void setDesc(String value) { this.desc = value; } public String getDir() { return dir; } public void setDir(String value) { this.dir = value; } public double getLat() { return lat; } public void setLat(double value) { this.lat = value; } public double getLng() { return lng; } public void setLng(double value) { this.lng = value; }
Update 2 . As far as I can tell, it does not work on the following code snippet (from Source ):
Class c = loader == null ? Class.forName(name) : Class.forName(name, true, loader);
Why can't he find a class? It exists and implements Parcelable .
java android marshalling parcelable
Jeremy Logan Jan 03 '09 at 21:02 2010-01-03 21:02
source share