简体   繁体   中英

How to list Android root processes

I'm trying to list all the currently running processes using the below code:

ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> processInfo = am.getRunningAppProcesses();
for (int i = 0; i < processInfo.size(); i++) {
Log.d("Process: ",""+processInfo.get(i).processName );
}

It is listing everything except the root processes like 'sh', 'strace' etc. can anyone tell how to list these also? They are being listed when executing 'ps' command via shell command prompt..

Execute the ps command via a shell and process and display the output yourself. ActivityManager will only return apps.

You can see the TerminalUtils class from my open source project for an example of running terminal commands through Java and getting the output into Strings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM