Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

Does this answer your question? getSerializableExtra and getParcelableExtra deprecated, What is the alternative? – Adil Hussain Jul 21 at 14:49

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!

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, 2022 at 7: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, 2022 at 7:59

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.