title: Running ps shell command on Android programmatically
body: <p>I'm trying to execute the ps command on my Android app, as such:</p>
  
  <pre><code>try {
      Process process = Runtime.getRuntime().exec("ps");
      BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
      int read;
      char[] buffer = new char[4096];
      StringBuffer output = new StringBuffer();
      while ((read = reader.read(buffer)) &gt; 0) {
          output.append(buffer, 0, read);
      }
      reader.close();
  
      // Waits for the command to finish.
      process.waitFor();
      Log.d(TAG, output.toString());
  } catch (IOException e) {
  
  } catch (InterruptedException e) {
  
  }
  </code></pre>
  
  <p>I'm testing it on a Samsung Galaxy S6 with Lollipop. It runs, but all I see are root-owned processes.</p>
  
  <p>On a Nexus 5 with Marshmallow though, I don't see root owned processes, but I see many other processes. It's still not a complete list.</p>
  
  <p>Is there some kind of protection within Android that prevents me from seeing the full process list in certain devices/OS versions?</p>