I have upgraded targetSdkVersion
and compileSdkVersion
to 33.
val picList =
result.data?.getParcelableArrayListExtra<PageNumberFile>(KEY_CAM_PIC_LIST)
It suggest me use Use the type-safer, What is the solution?
I have upgraded targetSdkVersion
and compileSdkVersion
to 33.
val picList =
result.data?.getParcelableArrayListExtra<PageNumberFile>(KEY_CAM_PIC_LIST)
It suggest me use Use the type-safer, What is the solution?
androidx.core:core-ktx provides IntentCompat
and androidx.core.os.BundleCompat
class, with the following method:
IntentCompat.getParcelableArrayListExtra(result.data, KEY_CAM_PIC_LIST, PageNumberFile::class.java)
To make it more convenient, you can create extensions:
inline fun <reified T : Parcelable> Bundle.parcelableList(key: String): List<T>? =
BundleCompat.getParcelableArrayList(this, key, T::class.java)
inline fun <reified T : Parcelable> Intent.parcelableList(key: String): List<T>? =
IntentCompat.getParcelableArrayListExtra(this, key, T::class.java)
Your best guide would be DOC
so you should use THIS
getParcelableArrayListExtra(String name, Class<? extends T> clazz)
. Note second argument, in your case it should bePageNumberFile::class.java
PS. I would post working snippet/line, but you have posted code as image and I can't copy it for improving and pasting in my answer and I won't be rewritting this, too lazy. Don't ever post text as not-copyable image!