How to find CPU load of any Android device programmatically

后端 未结 4 1274
南方客
南方客 2020-12-05 20:51

I want to have the same details in my android app. Anybody having any solution?

4条回答
  •  鱼传尺愫
    2020-12-05 21:32

    First, i've tried to parse the "top" command output to get overal usage, and my onw app. but I found that the results are totally different if I run the top from adb shell, or from the app. The app reported about a half CPU usage that was at adb (and android profiler tab too). So using top is not a solution.

    As I see it, you need to parse the "/proc/stat" file. Thanks to this question ,and code provided by Souch the job is already done for us. Just use his CpuInfo class to get the average load each time you need it.

提交回复
热议问题