ParcelableSerializer


public class ParcelableSerializer<T extends Parcelable> implements KSerializer


A serializer for Parcelable. This serializer uses SavedState's API directly to save/load a Parcelable.

Note that this serializer should be used with SavedStateEncoder or SavedStateDecoder only. Using it with other Encoders/Decoders may throw IllegalArgumentException.

import androidx.savedstate.serialization.serializers.ParcelableSerializer

@Serializable
data class MyModel(
    @Serializable(with = ParcelableSerializer::class) val parcelable: android.os.Parcelable
)

Summary

Public constructors

Public methods

final @NonNull T
final @NonNull SerialDescriptor
final void
serialize(@NonNull Encoder encoder, @NonNull T value)

Public constructors

ParcelableSerializer

public <T extends Parcelable> ParcelableSerializer()

Public methods

deserialize

Added in 1.3.0-alpha06
public final @NonNulldeserialize(@NonNull Decoder decoder)

getDescriptor

Added in 1.3.0-alpha06
public final @NonNull SerialDescriptor getDescriptor()

serialize

Added in 1.3.0-alpha06
public final void serialize(@NonNull Encoder encoder, @NonNull T value)