I've got a line of code like this:
val smsRetrieverStatus = extrasObj?.get(SmsRetriever.EXTRA_STATUS) as Status
But it's now deprecated as shown:

Is there any alternative way of doing this without getting deprecation warnings?
If you read the method documentation here, it says:
This method was deprecated in API level 33. Use the type-safe specific APIs depending on the type of the item to be retrieved, eg. getString(java.lang.String)
So, they're telling you to stop using the generic get() method, and instead use a type-specific one -- getString(), getInt(), getLong(), etc.
Update:
If you have a custom class or data type, then you'll need to implement your own logic to serialize that class (maybe use something like Gson). And once you've serialized it into a String, you can then use getString()
You can try another method
val status = extrasObj?.getParcelable(SmsRetriever.EXTRA_STATUS, Status::class.java)
Note that this method is not stable and sometimes throws NPE. So you'd better catch and handle the NPE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With