List of All running processes in Android

前端 未结 1 620
感情败类
感情败类 2021-02-01 19:47

How to get the list of Android system\'s All running process including System launched processes?

I tried to get the list using below code:

ActivityManager         


        
相关标签:
1条回答
  • 2021-02-01 20:18

    By calling an API from ActivityManager, you're only getting the applications which registered with it - that is, UI activities - and not all the processes. Those you see with a non-reverse DNS name, but a path (e.g. /system/bin/*) are native daemons, started by init, and left out of the ActivityManager.

    One way around this is to get the list of processes directly from /proc (just like toolbox's ps does it). This requires iterating programmatically over the directories there, (i.e. /proc/[0-9]*), and pruning out the kernel threads. Kernel threads are those with a PPID of 2, so they're easy. Native daemons will have a PPID of 1. Applications will have a PPID of Zygote.

    Reference: NewAndroidBook.com

    0 讨论(0)
提交回复
热议问题