public final class Parcel extends Object
Parcelable interface), and references to live IBinder
objects that will result in the other side receiving a proxy IBinder
connected with the original IBinder in the Parcel.
Parcel is not a general-purpose
serialization mechanism. This class (and the corresponding
Parcelable API for placing arbitrary objects into a Parcel) is
designed as a high-performance IPC transport. As such, it is not
appropriate to place any Parcel data in to persistent storage: changes
in the underlying implementation of any of the data in the Parcel can
render older data unreadable.
The bulk of the Parcel API revolves around reading and writing data of various types. There are six major classes of such functions available.
The most basic data functions are for writing and reading primitive
data types: writeByte(byte), readByte(), writeDouble(double),
readDouble(), writeFloat(float), readFloat(), writeInt(int),
readInt(), writeLong(long), readLong(),
writeString(java.lang.String), readString(). Most other
data operations are built on top of these. The given data is written and
read using the endianess of the host CPU.
There are a variety of methods for reading and writing raw arrays of primitive objects, which generally result in writing a 4-byte length followed by the primitive data items. The methods for reading can either read the data into an existing array, or create and return a new array. These available types are:
writeBooleanArray(boolean[]),
readBooleanArray(boolean[]), createBooleanArray()
writeByteArray(byte[]),
writeByteArray(byte[], int, int), readByteArray(byte[]),
createByteArray()
writeCharArray(char[]), readCharArray(char[]),
createCharArray()
writeDoubleArray(double[]), readDoubleArray(double[]),
createDoubleArray()
writeFloatArray(float[]), readFloatArray(float[]),
createFloatArray()
writeIntArray(int[]), readIntArray(int[]),
createIntArray()
writeLongArray(long[]), readLongArray(long[]),
createLongArray()
writeStringArray(String[]), readStringArray(String[]),
createStringArray().
writeSparseBooleanArray(SparseBooleanArray),
readSparseBooleanArray().
The Parcelable protocol provides an extremely efficient (but
low-level) protocol for objects to write and read themselves from Parcels.
You can use the direct methods writeParcelable(Parcelable, int)
and readParcelable(ClassLoader) or
writeParcelableArray(T[], int) and
readParcelableArray(ClassLoader) to write or read. These
methods write both the class type and its data to the Parcel, allowing
that class to be reconstructed from the appropriate class loader when
later reading.
There are also some methods that provide a more efficient way to work
with Parcelables: writeTypedObject(T, int), writeTypedArray(T[], int),
writeTypedList(java.util.List<T>), readTypedObject(android.os.Parcelable.Creator<T>),
createTypedArray(android.os.Parcelable.Creator<T>) and createTypedArrayList(android.os.Parcelable.Creator<T>). These methods
do not write the class information of the original object: instead, the
caller of the read function must know what type to expect and pass in the
appropriate Parcelable.Creator instead to
properly construct the new object and read its data. (To more efficient
write and read a single Parceable object that is not null, you can directly
call Parcelable.writeToParcel and
Parcelable.Creator.createFromParcel
yourself.)
A special type-safe container, called Bundle, is available
for key/value maps of heterogeneous values. This has many optimizations
for improved performance when reading and writing data, and its type-safe
API avoids difficult to debug type errors when finally marshalling the
data contents into a Parcel. The methods to use are
writeBundle(Bundle), readBundle(), and
readBundle(ClassLoader).
An unusual feature of Parcel is the ability to read and write active objects. For these objects the actual contents of the object is not written, rather a special token referencing the object is written. When reading the object back from the Parcel, you do not get a new instance of the object, but rather a handle that operates on the exact same object that was originally written. There are two forms of active objects available.
Binder objects are a core facility of Android's general cross-process
communication system. The IBinder interface describes an abstract
protocol with a Binder object. Any such interface can be written in to
a Parcel, and upon reading you will receive either the original object
implementing that interface or a special proxy implementation
that communicates calls back to the original object. The methods to use are
writeStrongBinder(IBinder),
writeStrongInterface(IInterface), readStrongBinder(),
#writeBinderArray(IBinder[]), #readBinderArray(IBinder[]),
#createBinderArray(),
#writeBinderList(List), #readBinderList(List),
#createBinderArrayList().
FileDescriptor objects, representing raw Linux file descriptor identifiers,
can be written and ParcelFileDescriptor objects returned to operate
on the original file descriptor. The returned file descriptor is a dup
of the original file descriptor: the object and fd is different, but
operating on the same underlying file stream, with the same position, etc.
The methods to use are writeFileDescriptor(FileDescriptor),
readFileDescriptor().
A final class of methods are for writing and reading standard Java
containers of arbitrary types. These all revolve around the
writeValue(Object) and readValue(ClassLoader) methods
which define the types of objects allowed. The container methods are
writeArray(Object[]), readArray(ClassLoader),
writeList(List), readList(List, ClassLoader),
readArrayList(ClassLoader),
writeMap(Map), readMap(Map, ClassLoader),
writeSparseArray(SparseArray),
readSparseArray(ClassLoader).
| Modifier and Type | Field and Description |
|---|---|
static Parcelable.Creator<String> |
STRING_CREATOR |
| Modifier and Type | Method and Description |
|---|---|
void |
appendFrom(Parcel parcel,
int offset,
int length) |
boolean[] |
createBooleanArray() |
byte[] |
createByteArray()
Read and return a byte[] object from the parcel.
|
char[] |
createCharArray() |
double[] |
createDoubleArray() |
float[] |
createFloatArray() |
int[] |
createIntArray() |
long[] |
createLongArray() |
FileDescriptor[] |
createRawFileDescriptorArray()
Read and return a new array of FileDescriptors from the parcel.
|
String[] |
createStringArray() |
ArrayList<String> |
createStringArrayList()
Read and return a new ArrayList containing String objects from
the parcel that was written with
writeStringList(java.util.List<java.lang.String>) at the
current dataPosition(). |
<T> T[] |
createTypedArray(Parcelable.Creator<T> c)
Read into the given List items IBinder objects that were written with
#writeBinderList at the current dataPosition(). |
<T> ArrayList<T> |
createTypedArrayList(Parcelable.Creator<T> c)
Read and return a new ArrayList containing a particular object type from
the parcel that was written with
writeTypedList(java.util.List<T>) at the
current dataPosition(). |
int |
dataAvail()
Returns the amount of data remaining to be read from the
parcel.
|
int |
dataCapacity()
Returns the total amount of space in the parcel.
|
int |
dataPosition()
Returns the current position in the parcel data.
|
int |
dataSize()
Returns the total amount of data contained in the parcel.
|
protected void |
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
long |
getBlobAshmemSize() |
static long |
getGlobalAllocSize() |
byte[] |
marshall()
Returns the raw bytes of the parcel.
|
static Parcel |
obtain()
Retrieve a new Parcel object from the pool.
|
protected static Parcel |
obtain(int obj) |
protected static Parcel |
obtain(long obj) |
boolean |
pushAllowFds(boolean allowFds) |
Object[] |
readArray(ClassLoader loader)
Read and return a new Object array from the parcel at the current
dataPosition().
|
ArrayList |
readArrayList(ClassLoader loader)
Read and return a CharSequence[] object from the parcel.
|
void |
readArrayMap(ArrayMap outVal,
ClassLoader loader) |
byte[] |
readBlob()
Read a blob of data from the parcel and return it as a byte array.
|
void |
readBooleanArray(boolean[] val) |
Bundle |
readBundle()
Read and return a new Bundle object from the parcel at the current
dataPosition().
|
Bundle |
readBundle(ClassLoader loader)
Read and return a new Bundle object from the parcel at the current
dataPosition(), using the given class loader to initialize the class
loader of the Bundle for later retrieval of Parcelable objects.
|
byte |
readByte()
Read a byte value from the parcel at the current dataPosition().
|
void |
readByteArray(byte[] val)
Read a byte[] object from the parcel and copy it into the
given byte array.
|
void |
readCharArray(char[] val) |
<T extends Parcelable> |
readCreator(Parcelable.Creator<?> creator,
ClassLoader loader) |
double |
readDouble()
Read a double precision floating point value from the parcel at the
current dataPosition().
|
void |
readDoubleArray(double[] val) |
void |
readException()
Special function for reading an exception result from the header of
a parcel, to be used after receiving the result of a transaction.
|
void |
readException(int code,
String msg)
Throw an exception with the given message.
|
int |
readExceptionCode()
Parses the header of a Binder call's response Parcel and
returns the exception code.
|
ParcelFileDescriptor |
readFileDescriptor()
Read a FileDescriptor from the parcel at the current dataPosition().
|
float |
readFloat()
Read a floating point value from the parcel at the current
dataPosition().
|
void |
readFloatArray(float[] val) |
HashMap |
readHashMap(ClassLoader loader)
Please use
readBundle(ClassLoader) instead (whose data must have
been written with writeBundle(android.os.Bundle). |
int |
readInt()
Read an integer value from the parcel at the current dataPosition().
|
void |
readIntArray(int[] val) |
void |
readList(List outVal,
ClassLoader loader)
Read into an existing List object from the parcel at the current
dataPosition(), using the given class loader to load any enclosed
Parcelables.
|
long |
readLong()
Read a long integer value from the parcel at the current dataPosition().
|
void |
readLongArray(long[] val) |
void |
readMap(Map outVal,
ClassLoader loader)
Please use
readBundle(ClassLoader) instead (whose data must have
been written with writeBundle(android.os.Bundle). |
<T extends Parcelable> |
readParcelable(ClassLoader loader)
Read and return a new Parcelable from the parcel.
|
Parcelable[] |
readParcelableArray(ClassLoader loader)
Read and return a new Parcelable array from the parcel.
|
Parcelable.Creator<?> |
readParcelableCreator(ClassLoader loader) |
PersistableBundle |
readPersistableBundle()
Read and return a new Bundle object from the parcel at the current
dataPosition().
|
PersistableBundle |
readPersistableBundle(ClassLoader loader)
Read and return a new Bundle object from the parcel at the current
dataPosition(), using the given class loader to initialize the class
loader of the Bundle for later retrieval of Parcelable objects.
|
FileDescriptor |
readRawFileDescriptor() |
void |
readRawFileDescriptorArray(FileDescriptor[] val)
Read an array of FileDescriptors from a parcel.
|
Serializable |
readSerializable()
Read and return a new Serializable object from the parcel.
|
Size |
readSize()
Read a Size from the parcel at the current dataPosition().
|
SizeF |
readSizeF()
Read a SizeF from the parcel at the current dataPosition().
|
SparseArray |
readSparseArray(ClassLoader loader)
Read and return a new SparseArray object from the parcel at the current
dataPosition().
|
SparseBooleanArray |
readSparseBooleanArray()
Read and return a new SparseBooleanArray object from the parcel at the current
dataPosition().
|
String |
readString()
Read a string value from the parcel at the current dataPosition().
|
String[] |
readStringArray()
Read and return a String[] object from the parcel.
|
void |
readStringArray(String[] val) |
void |
readStringList(List<String> list)
Read and return a new ArrayList containing IBinder objects from
the parcel that was written with
#writeBinderList at the
current dataPosition(). |
IBinder |
readStrongBinder()
Read an object from the parcel at the current dataPosition().
|
<T> T[] |
readTypedArray(Parcelable.Creator<T> c)
Deprecated.
|
<T> void |
readTypedArray(T[] val,
Parcelable.Creator<T> c) |
<T> void |
readTypedList(List<T> list,
Parcelable.Creator<T> c)
Read into the given List items containing a particular object type
that were written with
writeTypedList(java.util.List<T>) at the
current dataPosition(). |
<T> T |
readTypedObject(Parcelable.Creator<T> c)
Read and return a typed Parcelable object from a parcel.
|
Object |
readValue(ClassLoader loader)
Read a typed object from a parcel.
|
void |
recycle()
Put a Parcel object back into the pool.
|
void |
restoreAllowFds(boolean lastValue) |
void |
setDataCapacity(int size)
Change the capacity (current available space) of the parcel.
|
void |
setDataPosition(int pos)
Move the current read/write position in the parcel.
|
void |
setDataSize(int size)
Change the amount of data in the parcel.
|
void |
unmarshall(byte[] data,
int offset,
int length)
Set the bytes in data to be the raw bytes of this Parcel.
|
void |
writeArray(Object[] val)
Flatten an Object array into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeArrayMap(ArrayMap<String,Object> val) |
void |
writeBlob(byte[] b)
Write a blob of data into the parcel at the current
dataPosition(),
growing dataCapacity() if needed. |
void |
writeBlob(byte[] b,
int offset,
int len)
Write a blob of data into the parcel at the current
dataPosition(),
growing dataCapacity() if needed. |
void |
writeBooleanArray(boolean[] val) |
void |
writeBundle(Bundle val)
Flatten a Bundle into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeByte(byte val)
Write a byte value into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeByteArray(byte[] b)
Write a byte array into the parcel at the current
dataPosition(),
growing dataCapacity() if needed. |
void |
writeByteArray(byte[] b,
int offset,
int len)
Write a byte array into the parcel at the current
dataPosition(),
growing dataCapacity() if needed. |
void |
writeCharArray(char[] val) |
void |
writeDouble(double val)
Write a double precision floating point value into the parcel at the
current dataPosition(), growing dataCapacity() if needed.
|
void |
writeDoubleArray(double[] val) |
void |
writeException(Exception e)
Special function for writing an exception result at the header of
a parcel, to be used when returning an exception from a transaction.
|
void |
writeFileDescriptor(FileDescriptor val)
Write a FileDescriptor into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeFloat(float val)
Write a floating point value into the parcel at the current
dataPosition(), growing dataCapacity() if needed.
|
void |
writeFloatArray(float[] val) |
void |
writeInt(int val)
Write an integer value into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeIntArray(int[] val) |
void |
writeInterfaceToken(String interfaceName)
Report whether the parcel contains any marshalled file descriptors.
|
void |
writeList(List val)
Flatten a List into the parcel at the current dataPosition(), growing
dataCapacity() if needed.
|
void |
writeLong(long val)
Write a long integer value into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeLongArray(long[] val) |
void |
writeMap(Map val)
Please use
writeBundle(android.os.Bundle) instead. |
void |
writeNoException()
Special function for writing information at the front of the Parcel
indicating that no exception occurred.
|
void |
writeParcelable(Parcelable p,
int parcelableFlags)
Flatten the name of the class of the Parcelable and its contents
into the parcel.
|
<T extends Parcelable> |
writeParcelableArray(T[] value,
int parcelableFlags)
Write a heterogeneous array of Parcelable objects into the Parcel.
|
void |
writeParcelableCreator(Parcelable p) |
void |
writePersistableBundle(PersistableBundle val)
Flatten a PersistableBundle into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeRawFileDescriptor(FileDescriptor val)
This will be the new name for writeFileDescriptor, for consistency.
|
void |
writeRawFileDescriptorArray(FileDescriptor[] value)
Write an array of FileDescriptor objects into the Parcel.
|
void |
writeSerializable(Serializable s)
Write a generic serializable object in to a Parcel.
|
void |
writeSize(Size val)
Flatten a Size into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeSizeF(SizeF val)
Flatten a SizeF into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeSparseArray(SparseArray<Object> val)
Flatten a generic SparseArray into the parcel at the current
dataPosition(), growing dataCapacity() if needed.
|
void |
writeSparseBooleanArray(SparseBooleanArray val) |
void |
writeString(String val)
Write a string value into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeStringArray(String[] val) |
void |
writeStringList(List<String> val)
Flatten a List containing String objects into the parcel, at
the current dataPosition() and growing dataCapacity() if needed.
|
void |
writeStrongBinder(IBinder val)
Write an object into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
void |
writeStrongInterface(IInterface val)
Write an object into the parcel at the current dataPosition(),
growing dataCapacity() if needed.
|
<T extends Parcelable> |
writeTypedArray(T[] val,
int parcelableFlags)
Flatten a List containing IBinder objects into the parcel, at
the current dataPosition() and growing dataCapacity() if needed.
|
<T extends Parcelable> |
writeTypedList(List<T> val)
Flatten a List containing a particular object type into the parcel, at
the current dataPosition() and growing dataCapacity() if needed.
|
<T extends Parcelable> |
writeTypedObject(T val,
int parcelableFlags)
Flatten the Parcelable object into the parcel.
|
void |
writeValue(Object v)
Flatten a generic object in to a parcel.
|
public static final Parcelable.Creator<String> STRING_CREATOR
public static Parcel obtain()
public final void recycle()
public static long getGlobalAllocSize()
public final int dataSize()
public final int dataAvail()
dataSize()-dataPosition().public final int dataPosition()
dataSize().public final int dataCapacity()
dataSize(). The difference between it and dataSize() is the
amount of room left until the parcel needs to re-allocate its
data buffer.public final void setDataSize(int size)
size - The new number of bytes in the Parcel.public final void setDataPosition(int pos)
pos - New offset in the parcel; must be between 0 and
dataSize().public final void setDataCapacity(int size)
size - The new capacity of the parcel, in bytes. Can not be
less than dataSize() -- that is, you can not drop existing data
with this method.public final boolean pushAllowFds(boolean allowFds)
public final void restoreAllowFds(boolean lastValue)
public final byte[] marshall()
The data you retrieve here must not be placed in any kind of persistent storage (on local disk, across a network, etc). For that, you should use standard serialization or another kind of general serialization mechanism. The Parcel marshalled representation is highly optimized for local IPC, and as such does not attempt to maintain compatibility with data created in different versions of the platform.
public final void unmarshall(byte[] data,
int offset,
int length)
public final void appendFrom(Parcel parcel, int offset, int length)
public final void writeInterfaceToken(String interfaceName)
public final void writeByteArray(byte[] b)
dataPosition(),
growing dataCapacity() if needed.b - Bytes to place into the parcel.public final void writeByteArray(byte[] b,
int offset,
int len)
dataPosition(),
growing dataCapacity() if needed.b - Bytes to place into the parcel.offset - Index of first byte to be written.len - Number of bytes to write.public final void writeBlob(byte[] b)
dataPosition(),
growing dataCapacity() if needed.b - Bytes to place into the parcel.
public final void writeBlob(byte[] b,
int offset,
int len)
dataPosition(),
growing dataCapacity() if needed.b - Bytes to place into the parcel.offset - Index of first byte to be written.len - Number of bytes to write.
public final void writeInt(int val)
public final void writeLong(long val)
public final void writeFloat(float val)
public final void writeDouble(double val)
public final void writeString(String val)
public final void writeStrongBinder(IBinder val)
public final void writeStrongInterface(IInterface val)
public final void writeFileDescriptor(FileDescriptor val)
The file descriptor will not be closed, which may
result in file descriptor leaks when objects are returned from Binder
calls. Use ParcelFileDescriptor.writeToParcel(android.os.Parcel, int) instead, which
accepts contextual flags and will close the original file descriptor
if Parcelable.PARCELABLE_WRITE_RETURN_VALUE is set.
public final void writeRawFileDescriptor(FileDescriptor val)
public final void writeRawFileDescriptorArray(FileDescriptor[] value)
value - The array of objects to be written.public final void writeByte(byte val)
public final void writeMap(Map val)
writeBundle(android.os.Bundle) instead. Flattens a Map into the parcel
at the current dataPosition(),
growing dataCapacity() if needed. The Map keys must be String objects.
The Map values are written using writeValue(java.lang.Object) and must follow
the specification there.
It is strongly recommended to use writeBundle(android.os.Bundle) instead of
this method, since the Bundle class provides a type-safe API that
allows you to avoid mysterious type errors at the point of marshalling.
public final void writeBundle(Bundle val)
public final void writePersistableBundle(PersistableBundle val)
public final void writeSize(Size val)
public final void writeSizeF(SizeF val)
public final void writeList(List val)
writeValue(java.lang.Object) and must follow the specification there.public final void writeArray(Object[] val)
writeValue(java.lang.Object) and must follow the specification there.public final void writeSparseArray(SparseArray<Object> val)
writeValue(java.lang.Object) and must follow the
specification there.public final void writeSparseBooleanArray(SparseBooleanArray val)
public final void writeBooleanArray(boolean[] val)
public final boolean[] createBooleanArray()
public final void readBooleanArray(boolean[] val)
public final void writeCharArray(char[] val)
public final char[] createCharArray()
public final void readCharArray(char[] val)
public final void writeIntArray(int[] val)
public final int[] createIntArray()
public final void readIntArray(int[] val)
public final void writeLongArray(long[] val)
public final long[] createLongArray()
public final void readLongArray(long[] val)
public final void writeFloatArray(float[] val)
public final float[] createFloatArray()
public final void readFloatArray(float[] val)
public final void writeDoubleArray(double[] val)
public final double[] createDoubleArray()
public final void readDoubleArray(double[] val)
public final void writeStringArray(String[] val)
public final String[] createStringArray()
public final void readStringArray(String[] val)
public final <T extends Parcelable> void writeTypedList(List<T> val)
val - The list of objects to be written.createTypedArrayList(android.os.Parcelable.Creator<T>),
readTypedList(java.util.List<T>, android.os.Parcelable.Creator<T>),
Parcelablepublic final void writeStringList(List<String> val)
createStringArrayList() or
readStringList(java.util.List<java.lang.String>).val - The list of strings to be written.createStringArrayList(),
readStringList(java.util.List<java.lang.String>)public final <T extends Parcelable> void writeTypedArray(T[] val, int parcelableFlags)
#createBinderArrayList or
#readBinderList.val - The list of strings to be written.#createBinderArrayList,
#readBinderListpublic final <T extends Parcelable> void writeTypedObject(T val, int parcelableFlags)
val - The Parcelable object to be written.parcelableFlags - Contextual flags as per
Parcelable.writeToParcel().readTypedObject(android.os.Parcelable.Creator<T>)public final void writeValue(Object v)
Bundle
writeMap(java.util.Map)).
Parcelable protocol.
TextUtils#writeToParcel).
writeList(java.util.List)).
SparseArray (as supported by writeSparseArray(SparseArray)).
IBinder
writeSerializable(java.io.Serializable) for caveats). Note that all of the
previous types have relatively efficient implementations for
writing to a Parcel; having to rely on the generic serialization
approach is much less efficient and should be avoided whenever
possible.
Parcelable objects are written with
Parcelable.writeToParcel(android.os.Parcel, int) using contextual flags of 0. When
serializing objects containing ParcelFileDescriptors,
this may result in file descriptor leaks when they are returned from
Binder calls (where Parcelable.PARCELABLE_WRITE_RETURN_VALUE
should be used).
public final void writeParcelable(Parcelable p, int parcelableFlags)
p - The Parcelable object to be written.parcelableFlags - Contextual flags as per
Parcelable.writeToParcel().public final void writeParcelableCreator(Parcelable p)
public final void writeSerializable(Serializable s)
public final void writeException(Exception e)
The supported exception types are:
e - The Exception to be written.writeNoException(),
readException()public final void writeNoException()
public final void readException()
public final int readExceptionCode()
public final void readException(int code,
String msg)
code - Used to determine which exception class to throw.msg - The exception message.public final int readInt()
public final long readLong()
public final float readFloat()
public final double readDouble()
public final String readString()
public final IBinder readStrongBinder()
public final ParcelFileDescriptor readFileDescriptor()
public final FileDescriptor readRawFileDescriptor()
public final FileDescriptor[] createRawFileDescriptorArray()
public final void readRawFileDescriptorArray(FileDescriptor[] val)
public final byte readByte()
public final void readMap(Map outVal, ClassLoader loader)
readBundle(ClassLoader) instead (whose data must have
been written with writeBundle(android.os.Bundle). Read into an existing Map object
from the parcel at the current dataPosition().public final void readList(List outVal, ClassLoader loader)
public final HashMap readHashMap(ClassLoader loader)
readBundle(ClassLoader) instead (whose data must have
been written with writeBundle(android.os.Bundle). Read and return a new HashMap
object from the parcel at the current dataPosition(), using the given
class loader to load any enclosed Parcelables. Returns null if
the previously written map object was null.public final Bundle readBundle()
public final Bundle readBundle(ClassLoader loader)
public final PersistableBundle readPersistableBundle()
public final PersistableBundle readPersistableBundle(ClassLoader loader)
public final Size readSize()
public final SizeF readSizeF()
public final byte[] createByteArray()
public final void readByteArray(byte[] val)
public final byte[] readBlob()
public final String[] readStringArray()
public final ArrayList readArrayList(ClassLoader loader)
public final Object[] readArray(ClassLoader loader)
public final SparseArray readSparseArray(ClassLoader loader)
public final SparseBooleanArray readSparseBooleanArray()
public final <T> ArrayList<T> createTypedArrayList(Parcelable.Creator<T> c)
writeTypedList(java.util.List<T>) at the
current dataPosition(). Returns null if the
previously written list object was null. The list must have
previously been written via writeTypedList(java.util.List<T>) with the same object
type.writeTypedList(java.util.List<T>)public final <T> void readTypedList(List<T> list, Parcelable.Creator<T> c)
writeTypedList(java.util.List<T>) at the
current dataPosition(). The list must have
previously been written via writeTypedList(java.util.List<T>) with the same object
type.writeTypedList(java.util.List<T>)public final ArrayList<String> createStringArrayList()
writeStringList(java.util.List<java.lang.String>) at the
current dataPosition(). Returns null if the
previously written list object was null.writeStringList(java.util.List<java.lang.String>)public final void readStringList(List<String> list)
#writeBinderList at the
current dataPosition(). Returns null if the
previously written list object was null.#writeBinderListpublic final <T> T[] createTypedArray(Parcelable.Creator<T> c)
#writeBinderList at the current dataPosition().#writeBinderListpublic final <T> void readTypedArray(T[] val,
Parcelable.Creator<T> c)
@Deprecated public final <T> T[] readTypedArray(Parcelable.Creator<T> c)
public final <T> T readTypedObject(Parcelable.Creator<T> c)
writeTypedObject(T, int) with the same object type.writeTypedObject(T, int)public final <T extends Parcelable> void writeParcelableArray(T[] value, int parcelableFlags)
writeTypedArray(T[], int), but will
correctly handle an array containing more than one type of object.value - The array of objects to be written.parcelableFlags - Contextual flags as per
Parcelable.writeToParcel().writeTypedArray(T[], int)public final Object readValue(ClassLoader loader)
public final <T extends Parcelable> T readParcelable(ClassLoader loader)
loader - A ClassLoader from which to instantiate the Parcelable
object, or null for the default class loader.BadParcelableException - Throws BadParcelableException if there
was an error trying to instantiate the Parcelable.public final <T extends Parcelable> T readCreator(Parcelable.Creator<?> creator, ClassLoader loader)
public final Parcelable.Creator<?> readParcelableCreator(ClassLoader loader)
public final Parcelable[] readParcelableArray(ClassLoader loader)
public final Serializable readSerializable()
protected static final Parcel obtain(int obj)
protected static final Parcel obtain(long obj)
protected void finalize()
throws Throwable
ObjectNote that objects that override finalize are significantly more expensive than
objects that don't. Finalizers may be run a long time after the object is no longer
reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup.
Note also that finalizers are run on a single VM-wide finalizer thread,
so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary
for a class that has a native peer and needs to call a native method to destroy that peer.
Even then, it's better to provide an explicit close method (and implement
Closeable), and insist that callers manually dispose of instances. This
works well for something like files, but less well for something like a BigInteger
where typical calling code would have to deal with lots of temporaries. Unfortunately,
code that creates lots of temporaries is the worst kind of code from the point of view of
the single finalizer thread.
If you must use finalizers, consider at least providing your own
ReferenceQueue and having your own thread process that queue.
Unlike constructors, finalizers are not automatically chained. You are responsible for
calling super.finalize() yourself.
Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.
public void readArrayMap(ArrayMap outVal, ClassLoader loader)
public long getBlobAshmemSize()