ParcelCompat
class ParcelCompat
Helper for accessing features in Parcel.
Summary
Public functions |
|
|---|---|
java-static Array<Any!>? |
<T> readArray(in: Parcel, loader: ClassLoader?, clazz: Class<T!>)Same as |
java-static ArrayList<T!>? |
<T> readArrayList(in: Parcel, loader: ClassLoader?, clazz: Class<T!>)Same as |
java-static Boolean |
readBoolean(in: Parcel)Read a boolean value from the parcel at the current |
java-static HashMap<K!, V!>? |
<K, V> readHashMap(Same as |
java-static Unit |
Same as |
java-static Unit |
<K, V> readMap(Same as |
java-static T? |
<T : Parcelable?> readParcelable(Same as |
java-static Array<T!>? |
<T> This function is deprecated. This method incurs a performance penalty on SDK 33 and below. |
java-static Array<Parcelable!>? |
<T> readParcelableArrayTyped(Same as |
java-static Parcelable.Creator<T!>? |
@RequiresApi(value = 30)Same as |
java-static (Mutable)List<T!> |
@RequiresApi(api = Build.VERSION_CODES.Q)Same as |
java-static T? |
<T : Serializable?> readSerializable(Same as |
java-static SparseArray<T!>? |
<T> readSparseArray(in: Parcel, loader: ClassLoader?, clazz: Class<T!>)Same as |
java-static Unit |
writeBoolean(out: Parcel, value: Boolean)Write a boolean value into the parcel at the current f |
Public functions
readArray
java-static fun <T> readArray(in: Parcel, loader: ClassLoader?, clazz: Class<T!>): Array<Any!>?
Same as readArray but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the array elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
readArrayList
java-static fun <T> readArrayList(in: Parcel, loader: ClassLoader?, clazz: Class<T!>): ArrayList<T!>?
Same as readArrayList but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the list elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
readBoolean
java-static fun readBoolean(in: Parcel): Boolean
Read a boolean value from the parcel at the current dataPosition.
readHashMap
java-static fun <K, V> readHashMap(
in: Parcel,
loader: ClassLoader?,
clazzKey: Class<K!>,
clazzValue: Class<V!>
): HashMap<K!, V!>?
Same as readHashMap but accepts clazzKey and clazzValue parameter as the types required for each key and value pair. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the map entries' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
if the item to be deserialized is not an instance of that class or any of its children class. |
readList
java-static fun <T> readList(
in: Parcel,
outVal: (Mutable)List<T!>,
loader: ClassLoader?,
clazz: Class<T!>
): Unit
Same as readList but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the list elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
readMap
java-static fun <K, V> readMap(
in: Parcel,
outVal: (Mutable)Map<K!, V!>,
loader: ClassLoader?,
clazzKey: Class<K!>,
clazzValue: Class<V!>
): Unit
Same as readMap but accepts clazzKey and clazzValue parameter as the types required for each key and value pair. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the map entries' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
If the item to be deserialized is not an instance of that class or any of its children class. |
readParcelable
java-static fun <T : Parcelable?> readParcelable(
in: Parcel,
loader: ClassLoader?,
clazz: Class<T!>
): T?
Same as readParcelable but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, the object type is checked after deserialization.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
java-static fun <T>readParcelableArray(in: Parcel, loader: ClassLoader?, clazz: Class<T!>): Array<T!>?
Same as readParcelableArray but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the array elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
readParcelableArrayTyped
java-static fun <T> readParcelableArrayTyped(
in: Parcel,
loader: ClassLoader?,
clazz: Class<T!>
): Array<Parcelable!>?
Same as readParcelableArray but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the array elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
readParcelableCreator
@RequiresApi(value = 30)
java-static fun <T> readParcelableCreator(in: Parcel, loader: ClassLoader?, clazz: Class<T!>): Parcelable.Creator<T!>?
Same as readParcelableCreator but accepts clazz parameter as the required type. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the creator's type.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there there was an error trying to read the |
readParcelableList
@RequiresApi(api = Build.VERSION_CODES.Q)
java-static fun <T> readParcelableList(
in: Parcel,
list: (Mutable)List<T!>,
cl: ClassLoader?,
clazz: Class<T!>
): (Mutable)List<T!>
Same as readParcelableList but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the list elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
readSerializable
java-static fun <T : Serializable?> readSerializable(
in: Parcel,
loader: ClassLoader?,
clazz: Class<T!>
): T?
Same as readSerializable but accepts loader parameter as the primary classLoader for resolving the Serializable class; and clazz parameter as the required type. Compatibility behavior:
- SDK 33 and later, this method matches platform behavior.
- SDK 32 and below, this method will not check the item's type.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children class or there there was an error deserializing the object. |
readSparseArray
java-static fun <T> readSparseArray(in: Parcel, loader: ClassLoader?, clazz: Class<T!>): SparseArray<T!>?
Same as readSparseArray but accepts clazz parameter as the type required for each item. Compatibility behavior:
- SDK 34 and later, this method matches platform behavior.
- SDK 33 and below, this method will not check the array elements' types.
| Throws | |
|---|---|
android.os.BadParcelableException |
Throws BadParcelableException if the item to be deserialized is not an instance of that class or any of its children classes or there was an error trying to instantiate an element. |
writeBoolean
java-static fun writeBoolean(out: Parcel, value: Boolean): Unit
Write a boolean value into the parcel at the current fdataPosition, growing dataCapacity if needed.