codepath / codepath/android_guides

How to get the CPU usage details of an app for Android 8+

Open
#369 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
28.3k
Forks
6.2k
PR merge metrics
No merged PRs in 30d

Description

Hi all,

I am trying to get the amount of CPU being utilized by my app. I have searched for solutions online and all the answers suggest getting the details from /proc/stat which holds the details for all CPU numbers. I have tried the following solution posted on stackoverflow [link](https://stackoverflow.com/a/50088571/9359379) and the following [link](https://github.com/souch/AndroidCPU/blob/master/app/src/main/java/souch/androidcpu/CpuInfo.java).
However, It throws error `java.io.FileNotFoundException: /proc/stat: open failed: EACCES (Permission denied)`

On further searching of solution for this issue, I found out that the file /proc/stat/ has been disabled since Android 8.

So I request you kindly help me on getting the CPU usage details by this method or any alternate method.

Thank you

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.