Closed cbeyls closed 7 years ago
Thank you so much and for the detailed explanation! This explains a lot.
I was under the illusion that the ClassLoader
from the Bundle (which is set activity or fragment during restoration) will be used somehow "magically" internally as the view's state is restored from that bundle.
Again, thank you very much!
This fixes the crash described here.
This is not a bug in the framework or the support library. A
ClassLoader
must always be passed to anyParcelable
that usesParcel.readParcelable()
if the class to read is not a framework class. This includes the superState passed toAbsSavedState
orBaseSavedState
throughsuper()
.1) Using
ParcelableCompat.newCreator()
we are able to get aClassLoader
from the system. This is a thin wrapper around the nativeParcelable.ClassLoaderCreator
. We still check if it'snull
and provide a default one to be on the safe side, but it should never benull
in API 13+ if theParcelable
is created from a properly initializedBundle
. 2) Usingandroid.support.v4.view.AbsSavedState
instead ofView.BaseSavedState
we are able to pass thisClassLoader
tosuper()
so it's used to create the superState.