FileDocCategorySizeDatePackage
Parcelable.javaAPI DocAndroid 1.5 API4000Wed May 06 22:41:56 BST 2009android.os

Parcelable

public interface Parcelable
Interface for classes whose instances can be written to and restored from a {@link Parcel}. Classes implementing the Parcelable interface must also have a static field called CREATOR, which is an object implementing the {@link Parcelable.Creator Parcelable.Creator} interface.

A typical implementation of Parcelable is:

public class MyParcelable implements Parcelable {
private int mData;

public void writeToParcel(Parcel out, int flags) {
out.writeInt(mData);
}

public static final Parcelable.Creator CREATOR
= new Parcelable.Creator() {
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();
}
}

Fields Summary
public static final int
PARCELABLE_WRITE_RETURN_VALUE
Flag for use with {@link #writeToParcel}: the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)". Some implementations may want to release resources at this point.
public static final int
CONTENTS_FILE_DESCRIPTOR
Bit masks for use with {@link #describeContents}: each bit represents a kind of object considered to have potential special significance when marshalled.
Constructors Summary
Methods Summary
public intdescribeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.

return
a bitmask indicating the set of special object types marshalled by the Parcelable.

public voidwriteToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.

param
dest The Parcel in which the object should be written.
param
flags Additional flags about how the object should be written. May be 0 or {@link #PARCELABLE_WRITE_RETURN_VALUE}.