Android获取CPU编号

【Android获取CPU编号】生也有涯,知也无涯。这篇文章主要讲述Android获取CPU编号相关的知识,希望能为你提供帮助。

/** * 获取CPU序列号 * * @return CPU序列号(16位) * 读取失败为" 0000000000000000" */ private static String getCPUSerial() { if (Build.VERSION.SDK_INT > = Build.VERSION_CODES.O) { return Build.getSerial(); } //读取CPU信息 InputStreamReader inputStreamReader = null; BufferedReader bufferedReader = null; String cpu = null; try { Process process = Runtime.getRuntime().exec(" cat /proc/cpuinfo" ); inputStreamReader = new InputStreamReader(process.getInputStream()); bufferedReader = new BufferedReader(inputStreamReader); while ((cpu = bufferedReader.readLine()) != null) { if (cpu.contains(" Serial" )) { cpu = cpu.substring(cpu.indexOf(" :" ) + 1).trim(); break; } } } catch (IOException e) { e.printStackTrace(); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { e.printStackTrace(); } } if (inputStreamReader != null) { try { inputStreamReader.close(); } catch (IOException e) { e.printStackTrace(); } } } return cpu != null ? cpu.toUpperCase() : " 0000000000000000" ; }


    推荐阅读