标签:
1 public static void getRunningAppProcessInfo(ActivityManager mActivityManager) { 2 //ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); 3 4 if(mActivityManager != null) 5 { 6 //获得系统里正在运行的所有进程 7 List<RunningAppProcessInfo> runningAppProcessesList = mActivityManager.getRunningAppProcesses(); 8 9 for (RunningAppProcessInfo runningAppProcessInfo : runningAppProcessesList) { 10 // 进程ID号 11 int pid = runningAppProcessInfo.pid; 12 // 用户ID 13 int uid = runningAppProcessInfo.uid; 14 // 进程名 15 String processName = runningAppProcessInfo.processName; 16 // 占用的内存 17 int[] pids = new int[] {pid}; 18 Debug.MemoryInfo[] memoryInfo = mActivityManager.getProcessMemoryInfo(pids); 19 int memorySize = memoryInfo[0].dalvikPrivateDirty; 20 if(processName.equals("com.huofu")) 21 { 22 CommonUtils.LogWuwei(tag,"processName="+processName+",pid="+pid+"\nuid="+uid+"\nmemorySize="+memorySize/1024+"M"); 23 break; 24 } 25 26 } 27 } 28 else 29 { 30 CommonUtils.LogWuwei(tag, "mActivityManager is null"); 31 } 32 33 }
标签:
原文地址:http://www.cnblogs.com/kunyashaw/p/4337261.html