Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Parcelable对象在解组时提供ClassNotFoundException_Android_Android Intent_Classnotfoundexception_Parcelable_Badparcelableexception - Fatal编程技术网

Android Parcelable对象在解组时提供ClassNotFoundException

Android Parcelable对象在解组时提供ClassNotFoundException,android,android-intent,classnotfoundexception,parcelable,badparcelableexception,Android,Android Intent,Classnotfoundexception,Parcelable,Badparcelableexception,我写了两个包裹类,即预定物品和地点 ScheduleItem.java public class ScheduleItem implements Parcelable { private static final SimpleDateFormat FORMATTER = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z"); @SerializedName("start_date") private Da

我写了两个包裹类,即预定物品和地点

ScheduleItem.java

public class ScheduleItem  implements Parcelable {
    private static final SimpleDateFormat FORMATTER = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss Z");

    @SerializedName("start_date")
    private Date mStartDate;

    @SerializedName("end_date")
    private Date mEndDate;


        .............................
        getter & setter
        ............................


    private ScheduleItem(Parcel in) {

        long[] lngData = new long[2];

        in.readLongArray(lngData);
        this.mStartDate = new Date(lngData[0]);
        this.mEndDate = new Date(lngData[1]);
    }

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flag) {
        // TODO Auto-generated method stub
        out.writeLongArray(new long[]{ this.mStartDate.getTime(), this.mEndDate.getTime()});
    }

    public static final Parcelable.Creator<ScheduleItem> CREATOR = new Parcelable.Creator<ScheduleItem>() {
        public ScheduleItem createFromParcel(Parcel in) {
            return new ScheduleItem(in);
        }

        public ScheduleItem[] newArray(int size) {
            return new ScheduleItem[size];
        }
    };

}
public class Venue implements Parcelable {

    // Core fields
    @SerializedName("id")
    private long mId;

    @SerializedName("pcode")
    private int mPcode;

    @SerializedName("longitude")
    private double mLatitude;

    @SerializedName("latitude")
    private double mLongitude;

    @SerializedName("name")
    private String mName;

    @SerializedName("address")
    private String mAddress;

    @SerializedName("city")
    private String mCity;

    @SerializedName("state")
    private String mState;

    @SerializedName("zip")
    private String mZip;

    @SerializedName("phone")
    private String mPhone;

    // Super Bowl venue fields
    @SerializedName("tollfreephone")
    private String mTollFreePhone;

    private String mUrl;

    @SerializedName("description")
    private String mDescription;

    @SerializedName("ticket_link")
    private String mTicketLink;

    @SerializedName("image_url")
    private String mImageUrl;

    @SerializedName("schedule")
    private ArrayList<ScheduleItem> mSchedule = new ArrayList<ScheduleItem>();

    // computed fields
    private float mDistance;

    .............................
    getter & setter
    ............................

    private Venue(Parcel in) {

        this.mId = in.readLong();

        this.mPcode = in.readInt();

        double[] dbleData = new double[2];

        in.readDoubleArray(dbleData);
        this.mLatitude = dbleData[0];
        this.mLongitude = dbleData[1];

        String[] strData = new String[11];

        in.readStringArray(strData);
        this.mName = strData[0];
        this.mAddress = strData[1];
        this.mCity = strData[2];
        this.mState = strData[3];
        this.mZip = strData[4];
        this.mPhone = strData[5];
        this.mTollFreePhone = strData[6];
        this.mUrl = strData[7];
        this.mDescription = strData[8];
        this.mTicketLink = strData[9];
        this.mImageUrl = strData[10];

        this.mDistance = in.readFloat();

        List<ScheduleItem> tempSchedule = new ArrayList<ScheduleItem>();
        in.readList(tempSchedule, null);
        this.mSchedule = new ArrayList<ScheduleItem>(tempSchedule);

    }

    @Override
    public int describeContents() {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        // TODO Auto-generated method stub

        out.writeLong(this.mId);

        out.writeInt(this.mPcode);

        out.writeDoubleArray(new double[]{ this.mLatitude, this.mLongitude});

        out.writeStringArray(new String[] { this.mName, this.mAddress,
                this.mCity, this.mState, this.mZip, this.mPhone,
                this.mTollFreePhone, this.mUrl, this.mDescription,
                this.mTicketLink, this.mImageUrl });

        out.writeFloat(this.mDistance);

        out.writeList((List) this.mSchedule);
    }

    public static final Parcelable.Creator<Venue> CREATOR = new Parcelable.Creator<Venue>() {
        public Venue createFromParcel(Parcel in) {
            return new Venue(in);
        }

        public Venue[] newArray(int size) {
            return new Venue[size];
        }
    };

    public String toString(){
        return getName();
    }

}
在新的活动中,

地点MSelectedVincement=(地点)getIntent().getParcelableExtra( “venueDetails”)

当ArrayList
msSchedule
size为零时,它工作正常。但除此之外,在解组:com.ks.model.ScheduleItem时,它会抛出
android.os.BadParcelableException:ClassNotFoundException

我的代码有什么问题

Intent intent = new Intent();
intent.setClass(getActivity(), VenueDetailsActivity.class);
intent.putExtra("venueDetails", selectedVenue); //selectedVenue is a object of Venue
startActivity(intent);