Reputation: 11141
I am working on an App, where I need to show the CPU usage as per running applications(just like a Task manager).
I have followed this post, Get CPU usage, but it demonstrates the total CPU usage. Here it has used the following code to read the CPU stats,
RandomAccessFile reader = new RandomAccessFile("/proc/stat", "r");
I want to get cpu usage of all individually running apps. So far, I've been able to fetch the list of all running applications,
ActivityManager activityManager = (ActivityManager)
getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> listOfRunningProcess = activityManager
.getRunningAppProcesses();
Now I want to get the CPU usage for these applications.
Upvotes: 2
Views: 7371