0

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' e.t.c.. can anyone tell how to list these also? They are being listed when executing 'ps' command via shell command prompt..

srooth
  • 33
  • 2
  • 11

1 Answers1

0

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.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195
  • Thanks for replying Raghav..But what I want is the PID of strace process, if it is among the running processes. I'm not able to extract the PID from ps output, as the 'awk' command is not working in android shel..is there a way for it?? – srooth Feb 17 '13 at 15:53