Freigeben über


Parcel.ReadArray Method

Definition

Overloads

ReadArray(ClassLoader)

Read and return a new Object array from the parcel at the current dataPosition().

ReadArray(ClassLoader, Class)

Same as #readArray(ClassLoader) but accepts clazz parameter as the type required for each item.

ReadArray(ClassLoader)

Read and return a new Object array from the parcel at the current dataPosition().

[Android.Runtime.Register("readArray", "(Ljava/lang/ClassLoader;)[Ljava/lang/Object;", "")]
public Java.Lang.Object[]? ReadArray (Java.Lang.ClassLoader? loader);
[<Android.Runtime.Register("readArray", "(Ljava/lang/ClassLoader;)[Ljava/lang/Object;", "")>]
member this.ReadArray : Java.Lang.ClassLoader -> Java.Lang.Object[]

Parameters

loader
ClassLoader

Returns

Object[]
Attributes

Remarks

Read and return a new Object array from the parcel at the current dataPosition(). Returns null if the previously written array was null. The given class loader will be used to load any enclosed Parcelables.

This member is deprecated. Use the type-safer version #readArray(ClassLoader, Class) starting from Android Build.VERSION_CODES#TIRAMISU. Also consider changing the format to use #createTypedArray(Parcelable.Creator) if possible (eg. if the items' class is final) since this is also more performant. Note that changing to the latter also requires changing the writes.

Java documentation for android.os.Parcel.readArray(java.lang.ClassLoader).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ReadArray(ClassLoader, Class)

Same as #readArray(ClassLoader) but accepts clazz parameter as the type required for each item.

[Android.Runtime.Register("readArray", "(Ljava/lang/ClassLoader;Ljava/lang/Class;)[Ljava/lang/Object;", "", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public Java.Lang.Object[]? ReadArray (Java.Lang.ClassLoader? loader, Java.Lang.Class clazz);
[<Android.Runtime.Register("readArray", "(Ljava/lang/ClassLoader;Ljava/lang/Class;)[Ljava/lang/Object;", "", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
member this.ReadArray : Java.Lang.ClassLoader * Java.Lang.Class -> Java.Lang.Object[]

Parameters

loader
ClassLoader
clazz
Class

Returns

Object[]
Attributes

Remarks

Same as #readArray(ClassLoader) but accepts clazz parameter as the type required for each item.

<b>Warning: </b> if the list contains items implementing the Parcelable interface, the class that implements Parcelable has to be the immediately enclosing class of the runtime type of its CREATOR field (that is, Class#getEnclosingClass() has to return the parcelable implementing class), otherwise this method might throw an exception. If the Parcelable class does not enclose the CREATOR, use the deprecated #readArray(ClassLoader) instead.

Java documentation for android.os.Parcel.readArray(java.lang.ClassLoader, java.lang.Class<T>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to