我想使用類中的Parcelable將活動中的對象發送給另一個對象。我有一個Parcelable類,它有兩個字符串和一個Exception作爲屬性。可作爲屬性的異常類(Android)的可執行類
public class ReportErrorVO implements Parcelable {
private String titleError;
private String descriptionError;
private Exception exceptionError;
public ReporteErrorVO(Parcel in) {
titleError = in.readString();
descriptionError = in.readString();
exceptionError = ????; //What do I put here?
}
public ReporteErrorVO() {
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(titleError);
dest.writeString(descriptionError);
dest.writeException(exceptionError);
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public ReportErrorVO createFromParcel(Parcel in) {
return new ReportErrorVO(in);
}
public ReportErrorVO[] newArray(int size) {
return new ReportErrorVO[size];
}
};
@Override
public int describeContents() {
return 0;
}
//Getter and setters atributes...
}
如何在parcelable屬性中設置異常?
更正了拼寫。 –