Build.VERSION.SDK_INT 代表的操作系统的版本号 ,谷歌的解释大致翻译如下
当前在此硬件上运行的软件的SDK版本装置。当设备启动时,此值从不更改,但它可能当硬件制造商提供OTA更新时增加。
常用来判断sdk版本如下
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
}
后面的版本号,可以鼠标放到上面 +ctrl 按键就可以看到如下图
从源码里面看到当前有所的sdk 版本号
public static class VERSION_CODES {
public static final int BASE = 1;
public static final int BASE_1_1 = 2;
public static final int CUPCAKE = 3;
public static final int CUR_DEVELOPMENT = 10000;
public static final int DONUT = 4;
public static final int ECLAIR = 5;
public static final int ECLAIR_0_1 = 6;
public static final int ECLAIR_MR1 = 7;
public static final int FROYO = 8;
public static final int GINGERBREAD = 9;
public static final int GINGERBREAD_MR1 = 10;
public static final int HONEYCOMB = 11;
public static final int HONEYCOMB_MR1 = 12;
public static final int HONEYCOMB_MR2 = 13;
public static final int ICE_CREAM_SANDWICH = 14;
public static final int ICE_CREAM_SANDWICH_MR1 = 15;
public static final int JELLY_BEAN = 16;
public static final int JELLY_BEAN_MR1 = 17;
public static final int JELLY_BEAN_MR2 = 18;
public static final int KITKAT = 19;
public static final int KITKAT_WATCH = 20;
public static final int LOLLIPOP = 21;
public static final int LOLLIPOP_MR1 = 22;
public static final int M = 23;
public static final int N = 24;
public static final int N_MR1 = 25;
public static final int O = 26;
public static final int O_MR1 = 27;
public static final int P = 28;
public VERSION_CODES() {
throw new RuntimeException("Stub!");
}
}
作者:胡小牧