Partager via


Parcel.ReadSparseArray Method

Definition

Overloads

ReadSparseArray(ClassLoader, Class)

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

ReadSparseArray(ClassLoader)

Read and return a new SparseArray object from the parcel at the current dataPosition().

ReadSparseArray(ClassLoader, Class)

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

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

Parameters

loader
ClassLoader
clazz
Class

Returns

Attributes

Remarks

Same as #readSparseArray(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 #readSparseArray(ClassLoader) instead.

Java documentation for android.os.Parcel.readSparseArray(java.lang.ClassLoader, java.lang.Class<? extends 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

ReadSparseArray(ClassLoader)

Read and return a new SparseArray object from the parcel at the current dataPosition().

[Android.Runtime.Register("readSparseArray", "(Ljava/lang/ClassLoader;)Landroid/util/SparseArray;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public Android.Util.SparseArray? ReadSparseArray (Java.Lang.ClassLoader? loader);
[<Android.Runtime.Register("readSparseArray", "(Ljava/lang/ClassLoader;)Landroid/util/SparseArray;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
member this.ReadSparseArray : Java.Lang.ClassLoader -> Android.Util.SparseArray

Parameters

loader
ClassLoader

Returns

Attributes

Remarks

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

This member is deprecated. Use the type-safer version #readSparseArray(ClassLoader, Class) starting from Android Build.VERSION_CODES#TIRAMISU. Also consider changing the format to use #createTypedSparseArray(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.readSparseArray(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