extend Parcelable?

by Craig » Wed, 29 Oct 2008 23:14:33 GMT

Sponsored Links
 I have a class that extends a class that implements Parcelable. I have
instances of both classes in my app, and I would like to have the
subclass rely on the superclass' parceling methods for reading and
writing the superclass' variables, with the subclass only handling its
own extension.

It looks like there used to be a readFromParcel method on Parcelable
which would have suited my purpose, but with a static
Parcelable.Creator I'm not sure how to do it?

Anyone figure this out already?


extend Parcelable?

by Craig » Fri, 31 Oct 2008 00:24:05 GMT

 To answer my own question, I have what looks like a workable solution,
but I don't love it. Please add your improvements and offer better
suggestions, but I'd like to keep this conversation going.

I added a private no arg ctor to the superclass. The createFromParcel
method calls this, and then calls a static method on the superclass
that takes parameters of that class and a parcel. Subclass
Parcelable.CREATORs can do the same thing - create their own instance
and then call the superclass.setValues and pass the instance it is
creating. There isn't an issue writing the parcel - you can just call

This doesn't seem very elegant, and it may be slightly slower.

I may have 1 big class instead of splitting it up...

Sponsored Links

Other Threads

1. How to save browser page content?

Hi all:

I run some pages with JavaScript, and the result page is outputted by
JavaScript code.
So are there any easy methods to save the outputted content(mainly text)?

BTW, screen capture in SDK is not convenient for me.

Thanks, Xuezhi


2. hey all.. i need Android Application developmers

hey. i need android application developers for a leading IT company,
and also mobile application developers are also required

please contact me if you are available
at ravula.har...@gmail.com
or harshavardhan4...@yahoo.in



3. Recover/retrieve deleted files

4. GPS Road Network Developer

5. How to use "onTap" method to return to previous activity

6. Search function in Contact, Android 2.2

7. Issue during compilation of Android for beagle board