private void getRunningAppProcessInfo() { mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); //獲得系統裡正在運行的所有進程 List runningAppProcessesList = mActivityManager.getRunningAppProcesses(); for (RunningAppProcessInfo runningAppProcessInfo : runningAppProcessesList) { // 進程ID號 int pid = runningAppProcessInfo.pid; // 用戶ID int uid = runningAppProcessInfo.uid; // 進程名 String processName = runningAppProcessInfo.processName; // 占用的內存 int[] pids = new int[] {pid}; Debug.MemoryInfo[] memoryInfo = mActivityManager.getProcessMemoryInfo(pids); int memorySize = memoryInfo[0].dalvikPrivateDirty; System.out.println("processName="+processName+",pid="+pid+",uid="+uid+",memorySize="+memorySize+"kb"); } }