Parcelable中丢失的字符串

时间:2016-02-18 14:10:37

标签: android android-intent parcelable parcel

我正在创建一个闹钟应用程序,我在传递有关包裹重复日期的数据时遇到问题。我认为它可能是布尔数组的东西,所以我把它切换到String但仍然存在问题。

知道我的Parcelable对象有什么问题吗?

public Alarm(Parcel source) {
    mHour = source.readInt();
    mMinutes = source.readInt();
    mId = source.readInt();

    // Here string is empty ""
    String days = source.readString();  
    mDays = GeneralUtilities.daysStringToBoolean(days);

    mIsEnabled = source.readInt() != 0;
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(mHour);
    dest.writeInt(mMinutes);
    dest.writeLong(mId);

    // Here days is string "True,False ... "
    String days = GeneralUtilities.daysBooleanToString(mDays);
    dest.writeString(days);

    dest.writeInt((mIsEnabled ? 1 : 0));
}

public static final Creator<Alarm> CREATOR = new Creator<Alarm>() {
    @Override
    public Alarm createFromParcel(Parcel source) {
        return new Alarm(source);
    }

    @Override
    public Alarm[] newArray(int size) {
        return new Alarm[size];
    }
};

}

0 个答案:

没有答案