Is `Activity Results API` stable for production us...
# android
b
Is
Activity Results API
stable for production use?
g
Yes, it's released as part of stable release of Androidx, so it's stable now Also onActivityResult is officially deprecated and new result api is recommended approach
a
onActivityResult is not deprecated, it's simply lower level API than the androidx.activity result API in jetpack
b
Thanks for the update
a
it's very much not in
Activity
-
ComponentActivity
is trying to nudge you to use the newer API since it's easy to break the operation of the activity result APIs if you don't call super 🙂 https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:activity[…]ctivity/ComponentActivity.java;l=624?q=ComponentActivity.java
m
oh wow I saw the deprecation in ComponentActivity and just assumed it was deprecated everywhere - confusing if you ask me.
one gotcha with
ActivityResultContract
is that it is written in java so the generics do not support nullability - i.e. it’s easy to accidentally define the output type as non-null and then implement
parseResult
as nullable 😢
g
Well, of course, but you cannot use Result API with android.Activity out of the box, isn't it? Of course it cannot be deprecated on Android framework level, there is no replacement tnere But deprecation on ComponentActiviti affecta pretty much everyone. I think it's pretty rare for modern apps to not use Androidx activity