Home > other >  startActivityForResult is not showing as deprected in Android Studio
startActivityForResult is not showing as deprected in Android Studio

Time:10-31

Some time ago I worked on a new application and I noticed that startActivityForResult was deprecated so I had to use ActivityResultLauncher <Intent>

Now I am updating another application that works with startActivityForResult but Android Studio does not mark the method as deprecated, doing a little research I noticed that minSdkVersion must have the most recent API for Android Studio to show you deprecated methods, so now I have compileSdkVersion 31 and minSdkVersion 31 and I can already see many deprecated methods that I did not before, but startActivityForResult is still not marked, even I used the method "Analize> Inspect code" and followed the line "Java> Code maturity" but it does not show me as deprecated the times I used startActivityForResult

So I need your help to know why it is not marked as deprecated and this also makes me think the following, is there a possibility that there are more deprecated methods that I do not know and Android Studio does not show them to me?

I make the clarification that yesterday I updated Android Studio to the latest version (Android Studio Arctic Fox | 2020.3.1 Patch 3) thinking that this could be the problem but I was unsuccessful.

CodePudding user response:

startActivityForResult() on Activity is not deprecated.

However, startActivityForResult() on ComponentActivity is deprecated. ComponentActivity, roughly speaking, is the root of all activities in the Jetpack libraries. AppCompatActivity extends ComponentActivity.

So, my guess is that:

  • In the case where you are getting the deprecation warning, you are inheriting from ComponentActivity

  • In the case where you are not getting the deprecation warning, you are not inheriting from ComponentActivity

  • Related