0

I have upgraded targetSdkVersion and compileSdkVersion to 33.

Now I am getting this warning enter image description here

val picList =
           result.data?.getParcelableArrayListExtra<PageNumberFile>(KEY_CAM_PIC_LIST)

It suggest me use Use the type-safer, What is the solution?

Abdur Rehman
  • 1,247
  • 10
  • 13
  • Does this answer your question? [getSerializableExtra and getParcelableExtra deprecated, What is the alternative?](https://stackoverflow.com/questions/72571804/getserializableextra-and-getparcelableextra-deprecated-what-is-the-alternative) – Adil Hussain Jul 21 '23 at 14:49

1 Answers1

1

Your best guide would be DOC

This method was deprecated in API Level 33. Use the type-safer getParcelableArrayListExtra(java.lang.String, java.lang.Class) starting from Android Build.VERSION_CODES#TIRAMISU.

so you should use THIS getParcelableArrayListExtra(String name, Class<? extends T> clazz). Note second argument, in your case it should be PageNumberFile::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!

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32
snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • thanks, From where I can find out all deprecated android code in Tiramisu and code that is added in this version? – Abdur Rehman Dec 13 '22 at 07:49
  • yes, you ma introduce some `if` for OS version, on older, below Tiramisu, you may still safely use old way/method – snachmsm Dec 13 '22 at 07:59