I have a Location object in one of my other Venue object that implements Parcelable. How do I serialize this correctly in my writeToParcel method implementation? So here's some code:
public class Venue implements Parcelable{
public String id;
public String name;
public String address;
public Location location;
public String city;
public String state;
public String country;
public String postalCode;
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel desc, int flags) {
desc.writeString(id);
desc.writeString(state);
desc.writeString(name);
desc.writeString(address);
desc.writeString(postalCode);
desc.writeString(country);
desc.writeString(city);
//I am still missing on a way to serialize my Location object here
}
}
Here your have a snippet how to serialize parcable objects into your own parcel.
Location location;
public void writeToParcel(Parcel desc, int flags) {
location.writeToParcel(desc, flags);
/* do your other parcel stuff here */
}
public void readFromParcel(Parcel in) {
location=Location.CREATOR.createFromParcel(in);
/* do your other parcel stuff here */
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With