On the other hand, if `MyData` is `@Serializable`,...
# serialization
e
On the other hand, if
MyData
is
@Serializable
, then it opens the road to many formats at once. You can
JSON.stringify(obj)
or you can
ProtoBuf.dump(obj)
and to parcel it you’ll have to have some kind of a helper
Parceller
class and use it like
Parceller.writeTo(parcel, obj)
. You will not be able just to do
parcel.writeValue(obj)
, because a serializable object does not implement
android.os.Parcelable
,
Yes.
k
However. Android has some ceremony that comes with it. For example, there has to be a
public static final CREATOR
field. This makes it difficult to simply have a generic solution. How would this be handled?
e
This ceremony is only needed for
parcel.readValue()
. You will not be to read it like that with serializable. You'll do
Parceller.read<MyData>(parcel)