Android怎样获取CPU使用率
Android怎样获取CPU使用率
我的程序:
private String getCpu() {
ProcessBuilder cmd;
String result = "";
try {
String[] args = { "/system/bin/cat", "/proc/cpuinfo" };
cmd = new ProcessBuilder(args);
Process process = cmd.start();
InputStream in = process.getInputStream();
byte[] re = new byte[1024];
while (in.read(re) != -1) {
System.out.println(new String(re));
result = result + new String(re);
return result.toString();
}
in.close();
} catch (Exception ex) {
ex.printStackTrace();
}
return result.toString();
}
这只能获取CPU信息,要怎样获取CPU使用率,或者说是CPU负荷程度