问题
I want to get all running processes in my phone. I have tried this code
ActivityManager am = (ActivityManager)
getBaseContext().getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> pids = am.getRunningAppProcesses();
But this code returns only my process.
回答1:
ActivityManager am = (ActivityManager)this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> listProcess = am.getRunningAppProcesses();
for(RunningAppProcessInfo runningProInfo:listProcess){
Log.i("Running Processes", ":"+runningProInfo.processName);
}
Working code.
Hope this helps..
来源:https://stackoverflow.com/questions/39097007/cannot-get-all-running-android-processes