ParcelCompat

Added in 1.1.0

class ParcelCompat

Helper for accessing features in Parcel.

Summary

Public functions

java-static Array<Any!>?
readArray(in: Parcel, loader: ClassLoader?, clazz: Class)

Same as readArray but accepts clazz parameter as the type required for each item.

java-static ArrayList?
readArrayList(in: Parcel, loader: ClassLoader?, clazz: Class)

Same as readArrayList but accepts clazz parameter as the type required for each item.

java-static Boolean

Read a boolean value from the parcel at the current dataPosition.

java-static HashMap?
readHashMap(
    in: Parcel,
    loader: ClassLoader?,
    clazzKey: Class,
    clazzValue: Class
)

Same as readHashMap but accepts clazzKey and clazzValue parameter as the types required for each key and value pair.

java-static Unit
readList(
    in: Parcel,
    outVal: (Mutable)List,
    loader: ClassLoader?,
    clazz: Class
)

Same as readList but accepts clazz parameter as the type required for each item.

java-static Unit
readMap(
    in: Parcel,
    outVal: (Mutable)Map,
    loader: ClassLoader?,
    clazzKey: Class,
    clazzValue: Class
)

Same as readMap but accepts clazzKey and clazzValue parameter as the types required for each key and value pair.

java-static T?
Parcelable?> readParcelable(
    in: Parcel,
    loader: ClassLoader?,
    clazz: Class
)

Same as readParcelable but accepts clazz parameter as the type required for each item.

java-static Array?
readParcelableArray(in: Parcel, loader: ClassLoader?, clazz: Class)

This function is deprecated.

This method incurs a performance penalty on SDK 33 and below.

java-static Array<Parcelable!>?
readParcelableArrayTyped(
    in: Parcel,
    loader: ClassLoader?,
    clazz: Class
)

Same as readParcelableArray but accepts clazz parameter as the type required for each item.

java-static Parcelable.Creator?
@RequiresApi(value = 30)
readParcelableCreator(in: Parcel, loader: ClassLoader?, clazz: Class)

Same as readParcelableCreator but accepts clazz parameter as the required type.

java-static (Mutable)List
@RequiresApi(api = Build.VERSION_CODES.Q)
readParcelableList(
    in: Parcel,
    list: (Mutable)List,
    cl: ClassLoader?,
    clazz: Class
)

Same as readParcelableList but accepts clazz parameter as the type required for each item.

java-static T?
Serializable?> readSerializable(
    in: Parcel,
    loader: ClassLoader?,
    clazz: Class
)

Same as readSerializable but accepts loader parameter as the primary classLoader for resolving the Serializable class; and clazz parameter as the required type.

java-static SparseArray?
readSparseArray(in: Parcel, loader: ClassLoader?, clazz: Class)

Same as readSparseArray but accepts clazz parameter as the type required for each item.

java-static Unit
writeBoolean(out: Parcel, value: Boolean)

Write a boolean value into the parcel at the current fdataPosition, growing dataCapacity if needed.

Public functions

readArray

Added in 1.9.0
java-static fun  readArray(in: Parcel, loader: ClassLoader?, clazz: Class): 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

Added in 1.9.0
java-static fun  readArrayList(in: Parcel, loader: ClassLoader?, clazz: Class): ArrayList?

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

Added in 1.1.0
java-static fun readBoolean(in: Parcel): Boolean

Read a boolean value from the parcel at the current dataPosition.

readHashMap

Added in 1.9.0
java-static fun  readHashMap(
    in: Parcel,
    loader: ClassLoader?,
    clazzKey: Class,
    clazzValue: Class
): HashMap?

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

Added in 1.9.0
java-static fun  readList(
    in: Parcel,
    outVal: (Mutable)List,
    loader: ClassLoader?,
    clazz: Class
): 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

Added in 1.9.0
java-static fun  readMap(
    in: Parcel,
    outVal: (Mutable)Map,
    loader: ClassLoader?,
    clazzKey: Class,
    clazzValue: Class
): 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

Added in 1.9.0
java-static fun Parcelable?> readParcelable(
    in: Parcel,
    loader: ClassLoader?,
    clazz: Class
): 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.

readParcelableArray

Added in 1.9.0
Deprecated in 1.10.0
java-static fun  readParcelableArray(in: Parcel, loader: ClassLoader?, clazz: Class): Array?

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

Added in 1.10.0
java-static fun  readParcelableArrayTyped(
    in: Parcel,
    loader: ClassLoader?,
    clazz: Class
): 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

Added in 1.9.0
@RequiresApi(value = 30)
java-static fun  readParcelableCreator(in: Parcel, loader: ClassLoader?, clazz: Class): Parcelable.Creator?

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 Parcelable.Creator.

readParcelableList

Added in 1.9.0
@RequiresApi(api = Build.VERSION_CODES.Q)
java-static fun  readParcelableList(
    in: Parcel,
    list: (Mutable)List,
    cl: ClassLoader?,
    clazz: Class
): (Mutable)List

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

Added in 1.9.0
java-static fun Serializable?> readSerializable(
    in: Parcel,
    loader: ClassLoader?,
    clazz: Class
): 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

Added in 1.9.0
java-static fun  readSparseArray(in: Parcel, loader: ClassLoader?, clazz: Class): SparseArray?

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

Added in 1.1.0
java-static fun writeBoolean(out: Parcel, value: Boolean): Unit

Write a boolean value into the parcel at the current fdataPosition, growing dataCapacity if needed.