Package android.os
Interface Parcelable
-
- All Known Implementing Classes:
Bundle,Configuration,ContentValues,CursorWindow,Debug.MemoryInfo,Message,Messenger,PackageInfo,ParcelableParcel,ParcelFileDescriptor,PersistableBundle
public interface ParcelableInterface for classes whose instances can be written to and restored from aParcel. Classes implementing the Parcelable interface must also have a non-null static field calledCREATORof a type that implements theParcelable.Creatorinterface.A typical implementation of Parcelable is:
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(); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceParcelable.ClassLoaderCreator<T>Specialization ofParcelable.Creatorthat allows you to receive the ClassLoader the object is being created in.static interfaceParcelable.Creator<T>Interface that must be implemented and provided as a public CREATOR field that generates instances of your Parcelable class from a Parcel.
-
Field Summary
Fields Modifier and Type Field Description static intCONTENTS_FILE_DESCRIPTORBit masks for use withdescribeContents(): each bit represents a kind of object considered to have potential special significance when marshalled.static intPARCELABLE_WRITE_RETURN_VALUEFlag for use withwriteToParcel(android.os.Parcel, int): 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)".
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intdescribeContents()Describe the kinds of special objects contained in this Parcelable's marshalled representation.voidwriteToParcel(Parcel dest, int flags)Flatten this object in to a Parcel.
-
-
-
Field Detail
-
PARCELABLE_WRITE_RETURN_VALUE
static final int PARCELABLE_WRITE_RETURN_VALUE
Flag for use withwriteToParcel(android.os.Parcel, int): 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.- See Also:
- Constant Field Values
-
CONTENTS_FILE_DESCRIPTOR
static final int CONTENTS_FILE_DESCRIPTOR
Bit masks for use withdescribeContents(): each bit represents a kind of object considered to have potential special significance when marshalled.- See Also:
- Constant Field Values
-
-
Method Detail
-
describeContents
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.- Returns:
- a bitmask indicating the set of special object types marshalled by the Parcelable.
-
writeToParcel
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.- Parameters:
dest- The Parcel in which the object should be written.flags- Additional flags about how the object should be written. May be 0 orPARCELABLE_WRITE_RETURN_VALUE.
-
-