需要说明在写日期的价值Parceable类的机器人机器人、日期、价值、Parceable

2023-09-04 03:57:42 作者:傻完了、就长大了

我们正在空指针异常而写的日期值Parceable类的机器人。

我们想知道什么是写日期值Parceable类的正确方法

这是在code为Parceable类

 的Bean;
进口的java.util.Calendar;
进口java.util.Date;

。进口COM pregnancycompanionapp.companion.R;

进口android.os.Parcel;
进口android.os.Parcelable;

/ **
 * DAO的期待母亲。
 *
 * @author马格努斯·达尔
 * /
公共类妈咪实现Parcelable,序列化{

    私有静态最后长的serialVersionUID = 1L;
    私人日期mDueDate = Calendar.getInstance()的getTime()。
    私人诠释mMode服务= Utils.LAST_PERIOD_DAYS;
    私人诠释法师;
    私人诠释mWeightPounds;
    私人浮动mWeightKG;
    私人诠释mHeightFeet;
    私人诠释mHeightInches;
    私人浮动mHeightCM;
    私人诠释mExercise = Utils.NONE;
    私人字符串mDoctorsNumber;
    私人诠释mTheme = R.style.theme_purple;
    私人诠释mMeasurement = R.string.SET_U_S__KEY;
    私人浮动动态混合注入;
    私人浮动mBMR;
    私人诠释MID;
    私人日期mCurrentDate;
    私人布尔mSoundEnabled;
    //私人地图<整数,整数GT; userSyncPeriods;
    //私人SparseArray< Parcelable> userSyncPeriods;

    / **
     * TODO:常量说明进入这里。
     * /
    公共静态最终Parcelable.Creator<妈妈> CREATOR =新Parcelable.Creator<妈妈>(){

        / **
         * @see android.os.Parcelable.Creator#createFromParcel(android.os.Parcel)
         * /
        @覆盖
        公共妈咪createFromParcel(以最终地块){
            返回新妈咪(中);
        }

        / **
         * @see android.os.Parcelable.Creator#newArray(INT)
         * /
        @覆盖
        公共妈咪[] newArray(最终诠释大小){
            返回新妈咪【尺寸】;
        }
    };

    / **
     * TODO:构造描述开始在这里。
     * /
    公共妈咪(){
        //
    }

    / **
     * TODO:构造描述开始在这里。
     *
     *在@param
     * /
    // @燮pressWarnings(未登记)
    / *修改于19-APR-2013(开始)
     *原因修改:读取​​包裹应该是写的要包裹顺序相同的
     * * /
    公共妈咪(以最终地块){
        this.mMode = in.readInt();
        this.mDueDate =新的日期(in.readLong());
        this.mAge = in.readInt();
        this.mWeightPounds = in.readInt();
        this.mHeightFeet = in.readInt();
        this.mHeightInches = in.readInt();
        this.mExercise = in.readInt();
        this.mDoctorsNumber = in.readString();
        this.mTheme = in.readInt();
        this.mMeasurement = in.readInt();
        this.mBMI = in.readFloat();
        this.mBMR = in.readFloat();
        this.mWeightKG = in.readFloat();
        this.mHeightCM = in.readFloat();
        this.mID = in.readInt();
        this.mCurrentDate =新的日期(in.readLong());
        this.mSoundEnabled =(in.readByte()== 1);
        // this.userSyncPeriods =
        // in.readHashMap(HashMap.class.getClassLoader());
        // this.userSyncPeriods =
        // in.readSparseArray(SparseArray.class.getClassLoader());
    }
     / *修改于19-APR-2013(完)* /
    / **
     * @see android.os.Parcelable#describeContents()
     * /
    @覆盖
    公众诠释describeContents(){
        返回0;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回字符串
     * /
    公众诠释getAge(){
        返回this.mAge;
    }

    / **
     * TODO:方法说明进入这里。
     *
     返回:体重指数
     * /
    公众持股量getBMI(){
        返回this.mBMI;
    }

    / **
     * TODO:方法说明进入这里。
     *
     返回:在BMR
     * /
    公众持股量getBMR(){
        返回this.mBMR;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回日期
     * /
    公开日期getCurrentDate(){
        返回this.mCurrentDate;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回字符串
     * /
    公共字符串getDoctorsNumber(){
        返回this.mDoctorsNumber;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回日期
     * /
    公开日期getDueDate(){
        返回this.mDueDate;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回INT
     * /
    公众诠释getExercise(){
        返回this.mExercise;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回浮动
     * /
    公众持股量getHeightCM(){
        返回this.mHeightCM;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回INT
     * /
    公众诠释getHeightFeet(){
        返回this.mHeightFeet;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回INT
     * /
    公众诠释getHeightInches(){
        返回this.mHeightInches;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回整数
     * /
    公众诠释的getID(){
        返回this.mID;
    }

    / **
     * TODO:方法说明进入这里。
     *
     返回:测量
     * /
    公众诠释getMeasurement(){
        返回this.mMeasurement;
    }

    / **
     * TODO:方法说明进入这里。
     *
     返回:模式
     * /
    公众诠释获取模式(){
        返回this.mMode;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回整数
     * /
    公众诠释getTheme(){
        返回this.mTheme;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回浮动
     * /
    公众持股量getWeightKG(){
        返回this.mWeightKG;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回INT
     * /
    公众诠释getWeightPounds(){
        返回this.mWeightPounds;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @返回布尔
     * /
    公共布尔isSoundEnabled(){
        返回this.mSoundEnabled;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数年龄
     * /
    公共无效setAge(最后弦乐岁){
        如果((年龄=空)及!&安培;!(年龄=)){
            this.mAge =的Integer.parseInt(年龄);
        }
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数英伦
     *该BMI设置
     * /
    公共无效setBMI(最终浮动BMI){
        this.mBMI =体重指数;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数BMR
     *在BMR设置
     * /
    公共无效setBMR(最终浮动BMR){
        this.mBMR =基础代谢率;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数的currentdate
     * /
    公共无效setCurrentDate(决赛日期的currentdate){
        this.mCurrentDate =的currentdate;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数doctorsNumber
     * /
    公共无效setDoctorsNumber(最后弦乐doctorsNumber){
        this.mDoctorsNumber = doctorsNumber;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数的dueDate
     * /
    公共无效setDueDate(决赛日期的dueDate){
        this.mDueDate =的dueDate;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数运动
     * /
    公共无效setExercise(最终诠释运动){
        this.mExercise =运动;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数heightCM
     * /
    公共无效setHeightCM(最后弦乐heightCM){
        如果((heightCM = NULL)及!&安培;!(heightCM =)){
            如果(heightCM.contains(,))
            {
                串heightCMFix = heightCM.replace(,,。); //修复了逗号和句号的长数字可能的本地化问题
                this.mHeightCM = Float.parseFloat(heightCMFix);
            }
            其他
                this.mHeightCM = Float.parseFloat(heightCM);
        }
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数heightFeet
     * /
    公共无效setHeightFeet(最后弦乐heightFeet){
        如果((heightFeet = NULL)及!&安培;!(heightFeet =)){
            this.mHeightFeet =的Integer.parseInt(heightFeet);
        }
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数heightInches
     * /
    公共无效setHeightInches(最后弦乐heightInches){
        如果((heightInches =空)及!及(heightInches =)!){
            this.mHeightInches =的Integer.parseInt(heightInches);
        }
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数ID
     * /
    公共无效SETID(最终诠释的id){
        this.mID = ID;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数测量
     *测量来设置
     * /
    公共无效setMeasurement(最终诠释测量){
        this.mMeasurement =测量;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数模式
     *将模式设置
     * /
    公共无效setMode(最终诠释模式){
        this.mMode =模式;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数soundEnabled
     * /
    公共无效setSoundEnabled(最终诠释soundEnabled){
        如果(soundEnabled == 0){
            this.mSoundEnabled = FALSE;
        } 其他 {
            this.mSoundEnabled = TRUE;
        }
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数主题
     * /
    公共无效setTheme(最终诠释主题){
        this.mTheme =主题;
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数重量(kg)
     * /
    公共无效setWeightKG(最后弦乐重量kg){
        如果((重量(kg)= NULL)及!&安培;!(重量(kg)=)){
            this.mWeightKG = Float.parseFloat(重量kg);
        }
    }

    / **
     * TODO:方法说明进入这里。
     *
     * @参数weightPounds
     * /
    公共无效setWeightPounds(最后弦乐weightPounds){
        如果((weightPounds =空)及!及(weightPounds =)!){
            this.mWeightPounds =的Integer.parseInt(weightPounds);
        }
    }

    //公共地图<整数,整数GT; getUserSyncPeriods(){
    //返回this.userSyncPeriods;
    //}

    //公共无效setUserSyncPeriods(地图<整数,整数GT; userSyncPeriods){
    // this.userSyncPeriods = userSyncPeriods;
    //}

    / **
     * @see android.os.Parcelable#writeToParcel(android.os.Parcel,INT)
     * /
    @覆盖
    / *修改于19-APR-2013(开始)
     *原因修改:写入地块应该是同一顺序的从包裹阅读
     * * /
    公共无效writeToParcel(最终包裹DEST,最终诠释标志){
        dest.writeInt(this.mMode);
        dest.writeLong(this.mDueDate.getTime());
        dest.writeInt(this.mAge);
        dest.writeInt(this.mWeightPounds);
        dest.writeInt(this.mHeightFeet);
        dest.writeInt(this.mHeightInches);
        dest.writeInt(this.mExercise);
        dest.writeString(this.mDoctorsNumber);
        dest.writeInt(this.mTheme);
        dest.writeInt(this.mMeasurement);
        dest.writeFloat(this.mBMI);
        dest.writeFloat(this.mBMR);
        dest.writeFloat(this.mWeightKG);
        dest.writeFloat(this.mHeightCM);
        dest.writeInt(this.mID);
        dest.writeLong(this.mCurrentDate.getTime());
        dest.writeByte((字节)(this.mSoundEnabled?1:0));
        // dest.writeMap(this.userSyncPeriods);
        // dest.writeSparseArray((this.userSyncPeriods&其中; Parcelable&GT));
    }
     / *修改于19-APR-2013(完)* /
}
 
深度 国际教育行业 留学需求牵动千亿产业,中介及考培机构入口价值凸显

这是崩溃报告的堆栈跟踪

  1融为一体pregnancycompanionapp.companion.Mommy.writeToParcel Mommy.java,线473
2 android.os.Parcel.writeParcelable Parcel.java,线路1156
3 android.os.Parcel.writeValue Parcel.java,线路1075
4 android.os.Parcel.writeMapInternal Parcel.java,线493
5 android.os.Bundle.writeToParcel Bundle.java,线路1612
6 android.os.Parcel.writeBundle Parcel.java,线路507
7 android.support.v4.app.FragmentState.writeToParcel Fragment.java,线132
8 android.os.Parcel.writeTypedArray Parcel.java,线路1004
9 android.support.v4.app.FragmentManagerState.writeToParcel FragmentManager.java,线357
10 android.os.Parcel.writeParcelable Parcel.java,线路1156
11 android.os.Parcel.writeValue Parcel.java,线路1075
12 android.os.Parcel.writeMapInternal Parcel.java,线493
13 android.os.Bundle.writeToParcel Bundle.java,线路1612
14 android.os.Parcel.writeBundle Parcel.java,线路507
15 android.app.ActivityManagerProxy.activityStopped ActivityManagerNative.java,线路2002
16 android.app.ActivityThread.handleStopActivity ActivityThread.java,线路2878
17 android.app.ActivityThread.access $ 900个ActivityThread.java,线127
18 android.app.ActivityThread $ H.handleMessage ActivityThread.java,线路1176
19 android.os.Handler.dispatchMessage Handler.java,行99
20 android.os.Looper.loop Looper.java,线137
21 android.app.ActivityThread.main ActivityThread.java,线路4507
22 java.lang.reflect.Method.invokeNative
23 java.lang.reflect.Method.invoke Method.java,线511
24 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run ZygoteInit.java,线790
25 com.android.internal.os.ZygoteInit.main ZygoteInit.java,线557
26 dalvik.system.NativeStart.main
 

解决方案

 私人日期mDueDate = Calendar.getInstance()的getTime()。
 

而不是序列化Date对象,得到长RA presenting以毫秒为单位的时间,长的序列化。当你反序列化对象,你可以重新创建Date对象

We're getting Null Pointer Exception while writing Date value to Parceable Class in Android.

We wanted to know what is the correct way to write Date Value to Parceable class

This is the code for the Parceable Class

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import com.pregnancycompanionapp.companion.R;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * DAO for the expecting mother.
 * 
 * @author Magnus Dahl
 */
public class Mommy implements Parcelable, Serializable {

    private static final long serialVersionUID = 1L;
    private Date mDueDate = Calendar.getInstance().getTime();
    private int mMode = Utils.LAST_PERIOD_DAYS;
    private int mAge;
    private int mWeightPounds;
    private float mWeightKG;
    private int mHeightFeet;
    private int mHeightInches;
    private float mHeightCM;
    private int mExercise = Utils.NONE;
    private String mDoctorsNumber;
    private int mTheme = R.style.theme_purple;
    private int mMeasurement = R.string.SET_U_S__KEY;
    private float mBMI;
    private float mBMR;
    private int mID;
    private Date mCurrentDate;
    private boolean mSoundEnabled;
    // private Map<Integer, Integer> userSyncPeriods;
    // private SparseArray<Parcelable> userSyncPeriods;

    /**
     * TODO: Constant description goes in here.
     */
    public static final Parcelable.Creator<Mommy> CREATOR = new Parcelable.Creator<Mommy>() {

        /**
         * @see android.os.Parcelable.Creator#createFromParcel(android.os.Parcel)
         */
        @Override
        public Mommy createFromParcel(final Parcel in) {
            return new Mommy(in);
        }

        /**
         * @see android.os.Parcelable.Creator#newArray(int)
         */
        @Override
        public Mommy[] newArray(final int size) {
            return new Mommy[size];
        }
    };

    /**
     * TODO: Constructor description goes in here.
     */
    public Mommy() {
        //
    }

    /**
     * TODO: Constructor description goes in here.
     * 
     * @param in
     */
    // @SuppressWarnings("unchecked")
    /*Modified on 19-Apr-2013 (Start)
     * Reason for Modification: Read From Parcel should be of same order of Write To Parcel
     * */
    public Mommy(final Parcel in) {
        this.mMode = in.readInt();
        this.mDueDate = new Date(in.readLong());
        this.mAge = in.readInt();
        this.mWeightPounds = in.readInt();
        this.mHeightFeet = in.readInt();
        this.mHeightInches = in.readInt();
        this.mExercise = in.readInt();
        this.mDoctorsNumber = in.readString();
        this.mTheme = in.readInt();
        this.mMeasurement = in.readInt();
        this.mBMI = in.readFloat();
        this.mBMR = in.readFloat();
        this.mWeightKG = in.readFloat();
        this.mHeightCM = in.readFloat();
        this.mID = in.readInt();
        this.mCurrentDate = new Date(in.readLong());
        this.mSoundEnabled = (in.readByte() == 1);
        // this.userSyncPeriods =
        // in.readHashMap(HashMap.class.getClassLoader());
        // this.userSyncPeriods =
        // in.readSparseArray(SparseArray.class.getClassLoader());
    }
     /*Modified on 19-Apr-2013 (End)*/
    /**
     * @see android.os.Parcelable#describeContents()
     */
    @Override
    public int describeContents() {
        return 0;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return String
     */
    public int getAge() {
        return this.mAge;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return the BMI
     */
    public float getBMI() {
        return this.mBMI;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return the BMR
     */
    public float getBMR() {
        return this.mBMR;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return Date
     */
    public Date getCurrentDate() {
        return this.mCurrentDate;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return String
     */
    public String getDoctorsNumber() {
        return this.mDoctorsNumber;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return Date
     */
    public Date getDueDate() {
        return this.mDueDate;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return int
     */
    public int getExercise() {
        return this.mExercise;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return float
     */
    public float getHeightCM() {
        return this.mHeightCM;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return int
     */
    public int getHeightFeet() {
        return this.mHeightFeet;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return int
     */
    public int getHeightInches() {
        return this.mHeightInches;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return integer
     */
    public int getID() {
        return this.mID;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return the measurement
     */
    public int getMeasurement() {
        return this.mMeasurement;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return the mode
     */
    public int getMode() {
        return this.mMode;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return integer
     */
    public int getTheme() {
        return this.mTheme;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return float
     */
    public float getWeightKG() {
        return this.mWeightKG;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return int
     */
    public int getWeightPounds() {
        return this.mWeightPounds;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @return boolean
     */
    public boolean isSoundEnabled() {
        return this.mSoundEnabled;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param age
     */
    public void setAge(final String age) {
        if ((age != null) && (age != "")) {
            this.mAge = Integer.parseInt(age);
        }
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param bmi
     *            the BMI to set
     */
    public void setBMI(final float bmi) {
        this.mBMI = bmi;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param bmr
     *            the BMR to set
     */
    public void setBMR(final float bmr) {
        this.mBMR = bmr;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param currentDate
     */
    public void setCurrentDate(final Date currentDate) {
        this.mCurrentDate = currentDate;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param doctorsNumber
     */
    public void setDoctorsNumber(final String doctorsNumber) {
        this.mDoctorsNumber = doctorsNumber;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param dueDate
     */
    public void setDueDate(final Date dueDate) {
        this.mDueDate = dueDate;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param exercise
     */
    public void setExercise(final int exercise) {
        this.mExercise = exercise;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param heightCM
     */
    public void setHeightCM(final String heightCM) {
        if ((heightCM != null) && (heightCM != "")) {
            if(heightCM.contains(","))
            {
                String heightCMFix = heightCM.replace(",", "."); //fixes possible localization issues with commas and periods in long numbers
                this.mHeightCM = Float.parseFloat(heightCMFix);
            }
            else
                this.mHeightCM = Float.parseFloat(heightCM);
        }
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param heightFeet
     */
    public void setHeightFeet(final String heightFeet) {
        if ((heightFeet != null) && (heightFeet != "")) {
            this.mHeightFeet = Integer.parseInt(heightFeet);
        }
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param heightInches
     */
    public void setHeightInches(final String heightInches) {
        if ((heightInches != null) && (heightInches != "")) {
            this.mHeightInches = Integer.parseInt(heightInches);
        }
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param id
     */
    public void setID(final int id) {
        this.mID = id;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param measurement
     *            the measurement to set
     */
    public void setMeasurement(final int measurement) {
        this.mMeasurement = measurement;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param mode
     *            the mode to set
     */
    public void setMode(final int mode) {
        this.mMode = mode;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param soundEnabled
     */
    public void setSoundEnabled(final int soundEnabled) {
        if (soundEnabled == 0) {
            this.mSoundEnabled = false;
        } else {
            this.mSoundEnabled = true;
        }
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param theme
     */
    public void setTheme(final int theme) {
        this.mTheme = theme;
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param weightKG
     */
    public void setWeightKG(final String weightKG) {
        if ((weightKG != null) && (weightKG != "")) {
            this.mWeightKG = Float.parseFloat(weightKG);
        }
    }

    /**
     * TODO: Method description goes in here.
     * 
     * @param weightPounds
     */
    public void setWeightPounds(final String weightPounds) {
        if ((weightPounds != null) && (weightPounds != "")) {
            this.mWeightPounds = Integer.parseInt(weightPounds);
        }
    }

    // public Map<Integer, Integer> getUserSyncPeriods() {
    // return this.userSyncPeriods;
    // }

    // public void setUserSyncPeriods(Map<Integer, Integer> userSyncPeriods) {
    // this.userSyncPeriods = userSyncPeriods;
    // }

    /**
     * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
     */
    @Override
    /*Modified on 19-Apr-2013 (Start)
     * Reason for Modification: Write To Parcel should be of same order of read from Parcel
     * */
    public void writeToParcel(final Parcel dest, final int flags) {
        dest.writeInt(this.mMode);
        dest.writeLong(this.mDueDate.getTime());
        dest.writeInt(this.mAge);
        dest.writeInt(this.mWeightPounds);
        dest.writeInt(this.mHeightFeet);
        dest.writeInt(this.mHeightInches);
        dest.writeInt(this.mExercise);
        dest.writeString(this.mDoctorsNumber);
        dest.writeInt(this.mTheme);
        dest.writeInt(this.mMeasurement);
        dest.writeFloat(this.mBMI);
        dest.writeFloat(this.mBMR);
        dest.writeFloat(this.mWeightKG);
        dest.writeFloat(this.mHeightCM);
        dest.writeInt(this.mID);
        dest.writeLong(this.mCurrentDate.getTime());
        dest.writeByte((byte) (this.mSoundEnabled ? 1 : 0));
        // dest.writeMap(this.userSyncPeriods);
        // dest.writeSparseArray( (this.userSyncPeriods<Parcelable>));
    }
     /*Modified on 19-Apr-2013 (End)*/
}

And this is Stack Trace of the Crash Report

1   com.pregnancycompanionapp.companion.Mommy.writeToParcel Mommy.java, line 473
2   android.os.Parcel.writeParcelable   Parcel.java, line 1156
3   android.os.Parcel.writeValue    Parcel.java, line 1075
4   android.os.Parcel.writeMapInternal  Parcel.java, line 493
5   android.os.Bundle.writeToParcel Bundle.java, line 1612
6   android.os.Parcel.writeBundle   Parcel.java, line 507
7   android.support.v4.app.FragmentState.writeToParcel  Fragment.java, line 132
8   android.os.Parcel.writeTypedArray   Parcel.java, line 1004
9   android.support.v4.app.FragmentManagerState.writeToParcel   FragmentManager.java, line 357
10  android.os.Parcel.writeParcelable   Parcel.java, line 1156
11  android.os.Parcel.writeValue    Parcel.java, line 1075
12  android.os.Parcel.writeMapInternal  Parcel.java, line 493
13  android.os.Bundle.writeToParcel Bundle.java, line 1612
14  android.os.Parcel.writeBundle   Parcel.java, line 507
15  android.app.ActivityManagerProxy.activityStopped    ActivityManagerNative.java, line 2002
16  android.app.ActivityThread.handleStopActivity   ActivityThread.java, line 2878
17  android.app.ActivityThread.access$900   ActivityThread.java, line 127
18  android.app.ActivityThread$H.handleMessage  ActivityThread.java, line 1176
19  android.os.Handler.dispatchMessage  Handler.java, line 99
20  android.os.Looper.loop  Looper.java, line 137
21  android.app.ActivityThread.main ActivityThread.java, line 4507
22  java.lang.reflect.Method.invokeNative   
23  java.lang.reflect.Method.invoke Method.java, line 511
24  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run  ZygoteInit.java, line 790
25  com.android.internal.os.ZygoteInit.main ZygoteInit.java, line 557
26  dalvik.system.NativeStart.main

解决方案

 private Date mDueDate = Calendar.getInstance().getTime();

instead to serialize the Date object, get the long rapresenting the time in milliseconds and serialize that long. When you deserialize the object you can recreate the Date object