android TargetApi 和 SuppressLint
来源:互联网 发布:淘宝不能付款 编辑:程序博客网 时间:2024/05/18 02:32
TargetApi
@TargetApi(Build.VERSION_CODES.HONEYCOMB) 表示代码使用了新的api,该API 要求的最小版本是Build.VERSION_CODES.HONEYCOMB 也就是 android 3.0 这是一个精确的标识方式。此时Android的Lint工具不会提示错误。
我们在低版本设备上运行高版本API,程序有可能会崩溃,那么这时候就要根据不同的版本做兼容处理:
... if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { //3.0以上的API实现某种功能 } else { //3.0以下版本API实现同样功能 } ...
SuppressLint
@SuppressLint(“NewApi”) 告诉Lint代码中启用了新的api。不要提示错误。这个没有@TargetApi注解好,原因就是它没有显示的指明API的级别,开发者很难知晓这个API可以在哪些API等级上使用,如果运行在不兼容此API的机器上,容易崩溃。
0 0
- android TargetApi 和 SuppressLint
- 关于android的@TargetApi和@SuppressLint("NewApi")
- TargetAPI和SuppressLint
- Android中的@TargetApi and @SuppressLint
- android.annotation包中TargetApi和SuppressLint注解
- Android @SuppressLint("NewApi")和@TargetApi()的区别
- android下的SuppressLint与TargetApi
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi(number)使用比较
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- @SuppressLint("NewApi")和@TargetApi()的区别
- Android Volley完全解析(二),使用Volley加载网络图片
- Hadoop1.x与Hadoop2的区别
- iOS—keyWindow
- innobackupex 在线 备份及恢复数据库
- RCNN学习笔记(1):Rich feature hierarchies for accurate object detection and semantic segmentation
- android TargetApi 和 SuppressLint
- How to solve SQL Server Error 1222 i.e Unlock a SQL Server table
- Android Volley完全解析(三),定制自己的Request
- RCNN学习笔记(2):Rich feature hierarchies for accurate object detection and semantic segmentation
- c语言学习
- c++ 全局变量、局部变量、静态全局变量、静态局部变量的区别
- RCNN学习笔记(3):Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition(SPP-net)
- Android Volley完全解析(四),带你从源码的角度理解Volley
- Spring MVC 事物配置