int API_VERSION = 21;
@TargetApi(API_VERSION) 在 Android 中用于指定 API_VERSION 及以下版本支持该方法/类。
我们可以镜像类似的内容来指定仅 API_VERSION 及以上版本支持方法或类吗?
注意:- 我没有找到任何此类注释,但想询问社区是否遇到过类似的情况或实现了自己的注释?
最佳答案
有@RequiresApi
:
Denotes that the annotated element should only be called on the given API level or higher.
This is similar in purpose to the older @TargetApi annotation, but more clearly expresses that this is a requirement on the caller, rather than being used to "suppress" warnings within the method that exceed the minSdkVersion.
关于android - 是否有@minApi注释,类似于Android中的@TargetApi注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39732150/