Android下如何获取CPU序列号
来源:互联网 发布:钢结构设计软件下载 编辑:程序博客网 时间:2024/05/29 04:33
public static String getCPUSerial() {
String str = "", strCPU = "", cpuAddress = "0000000000000000";
try {
//读取CPU信息
Process pp = Runtime.getRuntime().exec("cat /proc/cpuinfo");
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
//查找CPU序列号
for (int i = 1; i < 100; i++) {
str = input.readLine();
if (str != null) {
//查找到序列号所在行
if (str.indexOf("Serial") > -1) {
//提取序列号
strCPU = str.substring(str.indexOf(":") + 1,
str.length());
//去空格
cpuAddress = strCPU.trim();
break;
}
} else {
//文件结尾
break;
}
}
} catch (Exception ex) {
//赋予默认值
ex.printStackTrace();
}
return cpuAddress;
}
注:有的系统下不能获取CPU序列号,结果都是"0000000000000000"
- Android下如何获取CPU序列号
- Android下如何获取CPU序列号
- Android下如何获取CPU序列号
- Android获取CPU序列号
- Android获取CPU序列号
- Android 获取cpu序列号
- android 获取CPU序列号
- android 获取CPU序列号
- Android中获取CPU序列号
- 关于CPU序列号的问题,以及如何获取×64下CPU的ProcessorID
- Android中获取手机cpu序列号
- 获取CPU序列号
- 获取cpu序列号
- 获取CPU序列号
- 获取cpu序列号
- 获取CPU序列号
- 获取cpu序列号
- 获取CPU序列号
- 广义欧几里得除法求sa+tb=(a,b)
- Android获取系统cpu信息,内存,版本,电量等信息
- mybatis 连接 sql server 2008
- boost string_algo简明使用
- Cracking the Coding Interview 150题(一)
- Android下如何获取CPU序列号
- 画布
- 内部类区别和用例
- XCODE6中使用iOS7 SDK的方法
- HDU 2089 不要62(数位DP)
- 谁说开源不能赚钱?
- 你知道Objective-C中一个很重要的数据类型Block的基本用法吗???
- 给程序员新手的一些建议
- 在spriteKit中加Button