Skip to content

Instantly share code, notes, and snippets.

@shau-lok
Created June 12, 2016 03:52
Show Gist options
  • Save shau-lok/a8a4c46f96f0d61bab70adbb374e3def to your computer and use it in GitHub Desktop.
Save shau-lok/a8a4c46f96f0d61bab70adbb374e3def to your computer and use it in GitHub Desktop.
Parcelable sample
public class MyParcelable implements Parcelable {
private int mData;
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mData);
}
public static final Parcelable.Creator<MyParcelable> CREATOR
= new Parcelable.Creator<MyParcelable>() {
public MyParcelable createFromParcel(Parcel in) {
return new MyParcelable(in);
}
public MyParcelable[] newArray(int size) {
return new MyParcelable[size];
}
};
private MyParcelable(Parcel in) {
mData = in.readInt();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment