Android 获取手机品牌、型号等信息

利用Build类,通过反射可以获得全部fields里的key和value.

 Field[] fields = Build.class.getFields();
  for (Field f : fields) {
   try {
         String name = f.getName();
         Object value = f.get(name);
//       String brand = f.get("BRAND").toString(); //Xiaomi
//       String model = f.get("MODEL").toString(); //Redmi Note 3

        System.out.println("key:" + name + ":value:" + value:" + value);
  } catch (IllegalAccessException e) {
    e.printStackTrace();
  }

打印结果:

key:BOARD:value:msm8952

key:BOOTLOADER:value:unknown

key:BRAND:value:Xiaomi

key:BUILDDATE:value:Fri Nov 25 12:39:19 CST 2016

key:CPU_ABI:value:arm64-v8a

key:CUSTOM_INTERNAL:value:unknown

key:CUSTOM_NAME:value:unknown

key:DEVICE:value:kenzo

key:DISPLAY:value:LMY47V

key:DISPLAY_HARDWARE:value:unknown

key:EXTERNAL:value:MI_M866

key:FINGERPRINT:value:Xiaomi/kenzo/kenzo:5.1.1/LMY47V/V8.0.7.0.LHOCNDG:user/release-keys

key:HARDWARE:value:qcom

key:HOST:value:c3-miui-ota-bd72.bj

key:ID:value:LMY47V

key:INTERNAL:value:MI_C0907_00_A

key:LCT_BSP_VERSION:value:0.5.3_0907

key:MANUFACTURER:value:Xiaomi

key:MODEL:value:Redmi Note 3

key:SERIAL:value:4138e824

key:TIME:value:1480048759000

........(太多了就不贴了)

你可能感兴趣的:(android实用)