版本号
Version | Codename | API | Distribution |
---|---|---|---|
2.3.3 - 2.3.7 | Gingerbread | 10 | 0.7% |
4.0.3 - 4.0.4 | Ice Cream Sandwich | 15 | 0.7% |
4.1.x | Jelly Bean | 16 | 2.7% |
4.2.x | - | 17 | 3.8% |
4.3 | - | 18 | 1.1% |
4.4 | KitKat | 19 | 16.0% |
5.0 | Lollipop | 21 | 7.4% |
5.1 | 22 | 21.8% | |
6.0 | Marshmallow | 23 | 32.3% |
7.0 | Nougat | 24 | 12.3% |
7.1 | 25 | 1.2% |
获取版本号
/**
* 获取Android发布的版本
*/
public static String getVersion() {
return android.os.Build.VERSION.RELEASE;
}
/**
* 获取SDK的API Level
* @return
*/
public static int getSDK() {
return android.os.Build.VERSION.SDK_INT;
}
版本号适配
6.0的权限
protected boolean hasPermission(String permission) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1)
return (checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED);
return true;
}
通知的副标题 API LEVEL16才能使用
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
builder.setSubText("it is really basic");
}
API Level建议写成版本名VERSION_CODES, 少用数字
网友评论