Implementing android.os.Parableable:
http://developer.android.com/reference/android/os/Parcelable.html
Basically, you add a little extra code to your object to explain how to serialize and deserialize it. That's why he lost information about your class, he does not know how to serialize it correctly. If I were you, I would convey the object of value through your intentions to the verses of the JSON object simply because I know that you know exactly what type of object you are transmitting. You get your Parcelable as follows:
getIntent().getExtras().getParcelable(key);
I know this probably looks like a little extra code, but I actually think this is a pretty clean way to exchange data between actions. You go through a strong type, you indicate how to blow it off / inflate it, and your actions need not have any working knowledge of each other.
In the value object, you simply fill in the spaces as follows:
public Person( Parcel in ) { String[] data = new String[2]; in.readStringArray(data); this.firstName = data[0]; this.lastName = data[1]; } public int describeContents() { return 0; } public void writeToParcel(Parcel dest, int flags) { dest.writeStringArray( new String[] { this.firstName, this.lastName, }); }
Hope this helps, maybe a little more code than what you were looking for, but this is a really clean solution, because when the targeted activity receives an object, you donβt have to worry about deserialization, which means cleaner code in your activity . Bold model, clean views :)
source share