I found this code to get Cpu freq. in Android:
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;
}
The problem is that the result is in Khz and not Mhz so i get something like: 300000
.. How can i convert in Mhz? A user wrote time ago that it found the solution using: result.trim()
as you can see here Convert khz value from CPU into mhz or ghz but he doesn't explain how use it.. Anyone knows? Thanks