The code is fine, when the bundle reads from the parcel it just extracts the
data.  It doesn't actually unparcel from that data until later when you
retrieve stuff from the bundle.

On Mon, Aug 10, 2009 at 10:54 AM, Bart van Wissen
<[email protected]>wrote:

>
> I have a parcelable class whose writeToParcel() method puts some data
> in a Bundle and writes it to the parcel.
> This parcel gets sent from a client process to a service process.
>
> At the side of the service, the readFromparcel() method tries to read
> this Bundle from the parcel. A strange thing happens here.
>
> First of all, I got a ClassNotFoundException for one of the objects
> inside the Bundle. I "fixed" this by using readBundle(this.getClass
> ().getClassloader()) to force it to use the application's
> classloader.
>
> After this, I no longer got the ClassNotFoundException, but I did get
> a different bundle, containing only the following entry:
> mParcelledData.dataSize=376
>
> This is not what's supposed to be in the bundle.
>
> In the sourcecode Parcel.java I see this, in the readBundle
> (Classloader) method:
>
> final Bundle bundle = new Bundle(this, length);
> if (loader != null) {
>  bundle.setClassLoader(loader);
> }
>
>
> So the classloader is set after reading the bundle, instead of before.
> Shouldn't that be the other way around?
>
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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