实体类实现Parcelable(包含boolean类型)
实体类实现Parcelable接口需要实现方法:
public ExtSignClockEntity(Parcel in) {
timeMess = in.readString();
repeatMess = in.readString();
label = in.readString();
ring = in.readString();
isRemind = in.readByte() != 0;
}
public static final Creator<ExtSignClockEntity> CREATOR = new Creator<ExtSignClockEntity>() {
@Override
public ExtSignClockEntity createFromParcel(Parcel in) {
return new ExtSignClockEntity(in);
}
@Override
public ExtSignClockEntity[] newArray(int size) {
return new ExtSignClockEntity[size];
}
};
@Override
public int describeContents() {
return 0;
} @Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(timeMess);
dest.writeString(repeatMess);
dest.writeString(label);
dest.writeString(ring);
dest.writeByte((byte)(isRemind?1:0));
}
其中boolean类型的数据输入输出分别为:boolean isCheck; Pacel parcel;
输入: parcel.readByte()!= 0;
输出: isCheck=parcel..writeByte((byte)(isCheck?1:0));