KDeogharkar
KDeogharkar

Reputation: 10959

Write Object data to a parcel

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

Upvotes: 3

Views: 4002

Answers (1)

Sam
Sam

Reputation: 86948

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.

Upvotes: 5

Related Questions