I don't think you are missing anything.  I haven't finished my test
either.  I am in the same situation.  My hunch is that the Parcel has
a lifecycle that must be followed.  By lifecycle I mean in the same
way that when you write to a nio ByteBuffer you call flip to prepare
the ByteBuffer for reading.  So we just have to find the lifecycle of
a Parcel.

Hope it helps.

James

On Feb 6, 2:05 pm, Lucius Fox <[email protected]> wrote:
> Hi,
>
> I follow the following example in creating a Parcelable 
> object:http://code.google.com/android/reference/android/os/Parcelable.html
>
> And I did the following to unit test the CREATOR and writeToParcel method:
>
>  Parcel dummyParcel = Parcel.obtain();
>  MyParcelable p = new MyParceable("12345");
> p.writeToParcel(dummyParcel,
> Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
>
>  MyParcelable p2 =  MyParcelable.CREATOR.createFromParcel(dummyParcel);
>
> System.out.println ("******** " + p.toString());
> System.out.println ("******** " + p2.toString());
>
> when I execute the method, p2 is empty.
>
> I step thru the code, the
>
>  private MyParcelable(Parcel in) {
>          mData = in.readInt();
>
> }
>
> did get called. But the readInt() return 0.
>
> Can you please tell me what am I missing?
>
> Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to