3

I want to Parcel the value that has datatype of "Object".
For that I am using writeValue(Object v) method.

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(lockMemberScore);
        dest.writeValue(lockFollowedMemberScore);
        dest.writeValue(lockGroupAvgScore);
    }

But It is giving me the following error

01-01 11:22:00.479: E/SyncService(9647): Parcel: unable to marshal value java.lang.Object@4122e3c0
KDeogharkar
  • 10,939
  • 7
  • 51
  • 95

1 Answers1

5

You cannot write a generic object to a Parcel.

The writeValue(Object v) can handle a long list of data types (available in the documentation) but a generic Object is not one of them... Basically your v is not: a primitive data type, Bundle, Map, etc and it does not implement Parcelable or Serializable; so writeValue() does know what to do with your particular Object.

Sam
  • 86,580
  • 20
  • 181
  • 179
  • ok @Sam so any otherway to marshal and unmarshal the generic object to parcel? – KDeogharkar Jan 01 '13 at 06:46
  • It's _really_ hard to say without more information. If you can turn this Object into a custom class that implements Parcelable then you can save this data to the Parcel. – Sam Jan 01 '13 at 06:58
  • I wrote an answer to another question awhile back that describes how to implement Parcelable, it may help you: [How to save custom ArrayList on Android screen rotate?](http://stackoverflow.com/a/12503875/1267661). – Sam Jan 01 '13 at 06:59
  • I am using this Object for the synchronization. – KDeogharkar Jan 01 '13 at 06:59