Build類包含哪些資訊
在專案的開發中,我們可能會與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;