You can use output of the top command, for your process
Here is what I did:
Runtime runtime = Runtime.getRuntime();
Process process;
String res = "-0-";
try {
String cmd = "top -n 1";
process = runtime.exec(cmd);
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line ;
while ((line = br.readLine()) != null) {
String segs[] = line.trim().split("[ ]+");
if (segs[0].equalsIgnoreCase([Your Process
ID])) {
res = segs[1];
break;
}
}
} catch (Exception e) {
e.fillInStackTrace();
Log.e("Process Manager", "Unable to execute top
command");
}
On May 4, 4:02 pm, Donald_W <[email protected]> wrote:
> Hello,
>
> How can I get/calculate current process CPU usage? ActivityManager
> provides method that returns a list of all active processes (list of
> RunningAppProcessInfo), but that class doesn't provide any CPU usage
> information.
>
> Thanks in advance,
> Tomek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---