5

I'm fairly new to Android, and am looking to track and log the overall CPU usage of a phone through an app that I'm making. Therefore, I'd like to be able to obtain the overall CPU usage as a % value, like 50%, 100%, etc., like how Task Manager in Windows displays the % usage of the CPU, or how other Android apps have a % CPU load (such as mentioned in this question: How to find CPU load of any Android device programmatically)

I've looked through several other Stack Overflow questions, but I haven't been able to find any answers that say whether I can get this CPU usage I'm looking for as a single value that I can store in a database and track over time.

These are some of the other questions I've looked at:

Get Memory Usage in Android

How to find CPU load of any Android device programmatically

How I get CPU usage and temperature information into an android app?

Yuerno
  • 751
  • 1
  • 8
  • 27
  • Hi, thanks for the reply. Would you be able to explain what that is/how to access that? Sorry if it's obvious, as mentioned earlier I'm pretty new to Android programming. – Yuerno Jan 21 '18 at 20:10
  • @Yuerno: I am not @MarcinOrlowski and this is pretty long ago, but I can try: `/proc/loadavg` is an artificial file that contains something like `1.1 2.2 3.3 4/5 6666`, where `1.1`/`2.2`/`3.3` are the number of processes that have something to do (so, 1 is ideal per core, above means there is waiting, `<0` means there is idle time) averaged for 1/5/15 minutes. `4/5` means *4 processes waiting for cpu time, 5 processes in total*. `6666` is the PID of the last active process. You can access the file with eg. `adb shell cat /proc/loadavg`. – Bowi May 19 '20 at 11:41

0 Answers0