I have 2 projects. 1 is Java, another 1 is Kotlin.

Both are using

implementation 'androidx.appcompat:appcompat:1.6.1'

However, I notice they are calling different function, when I try to call androidx.appcompat.app.AppCompatActivity.startActivityForResult(Intent, int)


In Java

When calling androidx.appcompat.app.AppCompatActivity.startActivityForResult(Intent, int), it will step into

androidx.activity.ComponentActivity.startActivityForResult(@NonNull Intent intent, int requestCode)

which is currently deprecated.

enter image description here


In Kotlin

When calling androidx.appcompat.app.AppCompatActivity.startActivityForResult(Intent, int), it will step into

androidx.fragment.app.FragmentActivity.startActivityForResult(@SuppressLint("UnknownNullness") Intent intent, int requestCode)

which is currently NOT deprecated.

enter image description here


The reason I start to look into this, is because I do not get expected deprecated warning when using startActivityForResult in Kotlin project.

When I investigate further, I notice Kotlin has different code path from Java, when calling androidx.appcompat.app.AppCompatActivity.startActivityForResult(Intent, int)

Is this the correct behavior? May I know why it is so?

0

There are 0 best solutions below