RequiresApi和TargetApi有什么区别?
kotlin的样品:
@RequiresApi(api = Build.VERSION_CODES.M) @TargetApi(Build.VERSION_CODES.M) class FingerprintHandlerM() : FingerprintManager.AuthenticationCallback()
注意:FingerprintManager.AuthenticationCallback需要api M
注2:如果我不使用TargetApi lint失败与错误类需要api级别23 …
解决方法
类似于Mike所说,正如您在文档中可以看到的那样:
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.
原文地址:https://www.jb51.cc/android/310122.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。