次の方法で共有


Parcel.ReadParcelable Method

Definition

Overloads

ReadParcelable(ClassLoader)

Read and return a new Parcelable from the parcel.

ReadParcelable(ClassLoader, Class)

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

ReadParcelable(ClassLoader)

Read and return a new Parcelable from the parcel.

[Android.Runtime.Register("readParcelable", "(Ljava/lang/ClassLoader;)Landroid/os/Parcelable;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T extends android.os.Parcelable" })]
public Java.Lang.Object? ReadParcelable (Java.Lang.ClassLoader? loader);
[<Android.Runtime.Register("readParcelable", "(Ljava/lang/ClassLoader;)Landroid/os/Parcelable;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T extends android.os.Parcelable" })>]
member this.ReadParcelable : Java.Lang.ClassLoader -> Java.Lang.Object

Parameters

loader
ClassLoader

A ClassLoader from which to instantiate the Parcelable object, or null for the default class loader.

Returns

Returns the newly created Parcelable, or null if a null object has been written.

Attributes

Exceptions

Throws BadParcelableException if there was an error trying to instantiate the Parcelable.

Remarks

Read and return a new Parcelable from the parcel. The given class loader will be used to load any enclosed Parcelables. If it is null, the default class loader will be used.

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

Java documentation for android.os.Parcel.readParcelable(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

ReadParcelable(ClassLoader, Class)

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

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

Parameters

loader
ClassLoader
clazz
Class

Returns

Attributes

Remarks

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

<b>Warning: </b> 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 #readParcelable(ClassLoader) instead.

Java documentation for android.os.Parcel.readParcelable(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