private void Getrunningappprocessinfo () {
Mactivitymanager = (Activitymanager) getsystemservice (Context.activity_service);
Get all the processes running in the system
list<runningappprocessinfo> runningappprocesseslist = mactivitymanager.getrunningappprocesses ();
for (Runningappprocessinfo runningappprocessinfo:runningappprocesseslist) {
Process ID Number
int pid = Runningappprocessinfo.pid;
User ID
int uid = RUNNINGAPPPROCESSINFO.UID;
Process Name
String processName = runningappprocessinfo.processname;
Memory occupied by
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");
}
}
Android Gets the amount of memory the app occupies