public class ParcelUtils extends Object
Parcel.| Modifier and Type | Method and Description |
|---|---|
static boolean |
readBoolean(android.os.Parcel in)
Read a
boolean value from the Parcel. |
static char |
readChar(android.os.Parcel in)
Read a
char value from the Parcel. |
static Serializable |
readSerializableWithPresenceFlag(android.os.Parcel in)
Read a
Serializable object from the Parcel. |
static String |
readStringWithPresenceFlag(android.os.Parcel in)
Read a
String object from the Parcel. |
static void |
writeBoolean(android.os.Parcel out,
boolean value)
Write a
boolean value into the Parcel. |
static void |
writeChar(android.os.Parcel out,
char value)
Write a
char value into the Parcel. |
static void |
writeSerializableWithPresenceFlag(android.os.Parcel out,
Serializable value)
Write a
Serializable object with a presence flag into the Parcel. |
static void |
writeStringWithPresenceFlag(android.os.Parcel out,
String value)
Write a
String object with a presence flag into the Parcel. |
public static boolean readBoolean(android.os.Parcel in)
boolean value from the Parcel.
This method reads one byte and returns true
if the read value is not 0.
in - Parcel to read from.boolean value read from the Parcel.public static void writeBoolean(android.os.Parcel out,
boolean value)
boolean value into the Parcel.
This method writes (byte)1 when value is true
and writes (byte)0 when value is false.
out - Parcel to write into.value - A boolean value to write.public static char readChar(android.os.Parcel in)
char value from the Parcel.
This method reads one int and converts the read value
into a char value.
in - Parcel to read from.char value read from the Parcel.public static void writeChar(android.os.Parcel out,
char value)
char value into the Parcel.
This method writes the given char value as int.
out - Parcel to write into.value - A char value to write.public static String readStringWithPresenceFlag(android.os.Parcel in)
String object from the Parcel.
First, this method reads a boolean value from the
Parcel using readBoolean(Parcel) method.
When the read boolean value is true, this
method executes in.readString()
and returns the value. Otherwise, when the read boolean value is false, this method returns
null.
in - Parcel to read from.String object or null.public static void writeStringWithPresenceFlag(android.os.Parcel out,
String value)
String object with a presence flag into the Parcel.
First, this method checks whether value is null or not.
When null, this method writes false into the Parcel
by calling writeBoolean(false) and
does nothing any more. Otherwise, when not null, this method writes
true by calling writeBoolean(true) and then writes the String object by calling
out.writeString(value).
out - Parcel to write into.value - A String object to write.public static Serializable readSerializableWithPresenceFlag(android.os.Parcel in)
Serializable object from the Parcel.
First, this method reads a boolean value from the
Parcel using readBoolean(Parcel) method.
When the read boolean value is true, this
method executes in.readSerializable() and returns the value. Otherwise,
when the read boolean value is false,
this method returns
null.
in - Parcel to read from.Serializable object or null.public static void writeSerializableWithPresenceFlag(android.os.Parcel out,
Serializable value)
Serializable object with a presence flag into the Parcel.
First, this method checks whether value is null or not.
When null, this method writes false into the Parcel
by calling writeBoolean(false) and
does nothing any more. Otherwise, when not null, this method writes
true by calling writeBoolean(true) and then writes the Serializable object by calling
out.writeSerializable(value).
out - Parcel to write into.value - A String object to write.Copyright © 2016. All rights reserved.