Search code examples
androidprocessrooted-devicedynamic-analysis

get detailed process information in Android


I'm going to write an app to do dynamic analysis of processes. In order to achieve this I want to have detailed statistics about process running on my phone.
Note: I have rooted phone so some limits are removed. So here is my question, how can I collect process information in detail dynamically? I know results of top,ps commands can help me, however I don't know how to call them or do I have access these commands on a rooted phone?
As I searched around the web ActivityManager.RunningAppProcessInfo is no longer useful since It provide limited information since Lolipop.


Solution

  • Linux top and ps are available even if the device is not rooted. You can run them from your app with Runtime.getRuntime().exec(). If you need to run a command "elevated", check this answer: https://stackoverflow.com/a/6953432/192373.

    Also, if your app has root permissions, it can examine the /proc filesystem, Linux style.