On Jul 15, 5:21 pm, Streets Of Boston <[email protected]> wrote:
> It looks like your Animal class is abstract and should never be
> constructed. Declare Animal 'abstract' and see if you get an
> instantiation error.

It should be abstract, but I cannot make it abstract because then I
cannot add the CREATOR to it, which is needed to implement
Parcelable.
So now it is just an empty superclass.


>
> Have your tried to put the 'public static final Parcelable.Creator
> CREATOR<Cat>' and 'public static final Parcelable.Creator
> CREATOR<Dog>' variables and definitions in both Cat and Dog (and not
> in Animal)? This will make sure that the factory-method
> createFromParcel creates the appropriate subclass (Cat or Dog, and not
> Animal).

I did that, but it doesn't work. Those CREATORs are never actually
called.
The AIDL compiler sees the List<Animal> and assumes that every element
in the list is an Animal, and no subclass of it, and it creates the
unmarshalling code accordingly.


> About the readFromParcel().
> If Cat and Dog both implement readFromParcel() it should work fine.
> Are you sure that the variable 'a' is not an Animal instance?
>

That was my mistake, I didn't properly override the method (one was
private and the other was public). I deleted my post when I noticed
this. Unfortunately this was while you were typing your reply.



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