The Short Answer:
It's set by the developer, And Android Studio just compares your minSdkVersion set in build.gradle file with the required api level.
The Longer Answer:
When you get this warning on a method, just CTRL+click on it to go to the source class, and there you will find it annotated @RequiresApi or/and @TargetApi, for example :
class MediaStore{
@RequiresApi(api = 29)
@TargetApi(29)
void setRequiredOriginal(...){}
}
Your build.gradle file:
defaultConfig {
minSdkVersion 23
...
}
Android Studio compares minSdkVersion to @RequiresApi or/and @TargetApi at the time you call the method MediaStore.setRequiredOriginal(...); and warn you if minSdkVersion is less that the recommended api.
Please note that there are differences between @RequiresApi and @TargetApi, sometimes you find them used along with each other but sometimes just one of them.
For more about difference between the two see: https://stackoverflow.com/a/50578783/10005752