Android APIs
public interface

Parcelable

android.os.Parcelable
Known Indirect Subclasses

Class Overview

Interface for classes whose instances can be written to and restored from a Parcel. Classes implementing the Parcelable interface must also have a non-null static field called CREATOR of a type that implements the Parcelable.Creator interface.

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();
     }
 }

Summary

Nested Classes
interface Parcelable.ClassLoaderCreator<T> Specialization of Parcelable.Creator that allows you to receive the ClassLoader the object is being created in. 
interface Parcelable.Creator<T> Interface that must be implemented and provided as a public CREATOR field that generates instances of your Parcelable class from a Parcel. 
Constants
int CONTENTS_FILE_DESCRIPTOR Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled.
int PARCELABLE_WRITE_RETURN_VALUE Flag for use with writeToParcel(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)".
Public Methods
abstract int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
abstract void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.

Constants

public static final int CONTENTS_FILE_DESCRIPTOR

Added in API level 1

Bit masks for use with describeContents(): each bit represents a kind of object considered to have potential special significance when marshalled.

Constant Value: 1 (0x00000001)

public static final int PARCELABLE_WRITE_RETURN_VALUE

Added in API level 1

Flag for use with writeToParcel(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.

Constant Value: 1 (0x00000001)

Public Methods

public abstract int describeContents ()

Added in API level 1

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

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

public abstract void writeToParcel (Parcel dest, int flags)

Added in API level 1

Flatten this object in to a Parcel.

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.