title: Is there a way to get Application CPU usage with Android 7 (nougat)
body: <p>In previous releases of Android I was able to get the CPU usage by using a top call </p>
  
  <pre><code>        String[] cmd = {
                  "sh",
                  "-c",
                  "top -m 1000 -d 0 -n 1 | grep \"" + aAppPID + "\""};
          lProcess = Runtime.getRuntime().exec(cmd);
          BufferedReader lReader = new BufferedReader(new InputStreamReader(lProcess.getInputStream()));
  </code></pre>
  
  <p>It appears that Android 7 has changed the security or something to not allow this.  Now, if attached to Android Studio it will give me a line with a CPU % of 1.  If running a release version I am seeing that it does not return any lines.  </p>
  
  <p>Does anyone know if there is a Permission that can be added to allow this? </p>
  
  <p>My best guess is that the permissions notes documented here have something to do with this problem.</p>
  
  <p><a href="https://developer.android.com/about/versions/nougat/android-7.0-changes.html#perm" rel="nofollow noreferrer">https://developer.android.com/about/versions/nougat/android-7.0-changes.html#perm</a></p>
  
  <p>Here is a link to another question that I posted a solution to get CPU usage on Pre-7 releases.</p>
  
  <p><a href="https://stackoverflow.com/questions/16726779/how-do-i-get-the-total-cpu-usage-of-an-application-from-proc-pid-stat/36462336#36462336">How do I get the total CPU usage of an application from /proc/pid/stat?</a></p>