Build类包含哪些信息
2018-10-09 本文已影响60人
奔跑吧李博
在项目的开发中,我们可能会与Build类打交道。例如,根据手机CPU的类型来进行so库的动态的下载;在用户登录时,可以获取用户手机型号,Android系统版本,手机序列号等信息。
Build类属于android.os包下,主要用于记录设备硬件和版本信息。
Build的内部类:VERSION_CODES,记录Android系统版本号常量,比如重要的14,21,23,24,26。
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; // 4.0
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; // 5.0
public static final int LOLLIPOP_MR1 = 22;
public static final int M = 23; // 6.0
public static final int N = 24; // 7.0
public static final int N_MR1 = 25;
public static final int O = 26; // 8.0
public static final int O_MR1 = 27;
public VERSION_CODES() {
throw new RuntimeException("Stub!");
}
}
Build的内部类VERSION,版本字符串
public static class VERSION {
public static final String BASE_OS = null;
public static final String CODENAME = null;
public static final String INCREMENTAL = null;
public static final int PREVIEW_SDK_INT = 0;
public static final String RELEASE = null; //系统版本
public static final String SDK = null; //SDK版本
public static final int SDK_INT = 0;
public static final String SECURITY_PATCH = null;
public VERSION() {
throw new RuntimeException("Stub!");
}
}
通过Build获取设备硬件信息:
public static final String BOARD = null; //主板
public static final String BOOTLOADER = null; //系统启动程序版本号
public static final String BRAND = null; //系统定制商
public static final String CPU_ABI = null; //cpu指令集
public static final String CPU_ABI2 = null; //cpu指令集2
public static final String DEVICE = null; //设备参数
public static final String DISPLAY = null; //显示屏参数
public static final String FINGERPRINT = null; //唯一识别码
public static final String HARDWARE = null; //硬件名称
public static final String HOST = null;
public static final String ID = null; //修订版本列表
public static final String MANUFACTURER = null; //硬件制造商
public static final String MODEL = null; //手机型号,比如xiaomi5,vivox21
public static final String PRODUCT = null; //手机制造商,比如Huawei
public static final String RADIO = null; //无线电固件版本
public static final String SERIAL = null; 硬件序列号
public static final String[] SUPPORTED_32_BIT_ABIS = null; //32位cpu指令集
public static final String[] SUPPORTED_64_BIT_ABIS = null; //64位cpu指令集
public static final String[] SUPPORTED_ABIS = null;
public static final String TAGS = null; //描述Build的标签
public static final long TIME = 0L;
public static final String TYPE = null; //build的类型
public static final String UNKNOWN = "unknown";
public static final String USER = null;