【发布时间】:2012-07-01 18:07:43
【问题描述】:
private String ReadCPUMhz()
{
ProcessBuilder cmd;
String result="";
int resultshow = 0;
try{
String[] args = {"/system/bin/cat", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"};
cmd = new ProcessBuilder(args);
Process process = cmd.start();
InputStream in = process.getInputStream();
byte[] re = new byte[1024];
while(in.read(re) != -1)
{
result = result + new String(re);
}
in.close();
} catch(IOException ex){
ex.printStackTrace();
}
return result;
}
我使用 setText 将结果中的值写入 textView。 所以它在应用程序启动时读出了当前的 cpu 频率并将其写入这个 textView。该应用程序显示 f.e. 1200Mhz 应用程序打开的整个时间。它没有更新值。
如何使用 Timer 或其他方法在 1s 或 250ms 后更新当前值并将其写入 textView? 它应该显示当前的 CPU 频率。 F.e.: 300Mhz - 1200Mhz.. 1s 或 250ms 后更新..
请帮帮我:-)
最好的问候
马库斯
【问题讨论】: