Tag:android memory process
public class Taskutils {/** * Gets the number of running processes * * @param context * @return */public static int Getrunningprocesscount (Contex T context) {//Get the system's task manager. Activitymanager am = (activitymanager) context.getsystemservice (context.activity_service); return Am.getrunningappprocesses (). Size ();} /** * Get the available memory of the phone * * @param context * @return The total available memory of long type data */public static long Getavailram (context context) {Activitym Anager am = (activitymanager) context.getsystemservice (Context.activity_service); Activitymanager.memoryinfo outinfo = new Memoryinfo (); Am.getmemoryinfo (outinfo); return outinfo.availmem;} /** * Get the total memory of the phone * * @return */public static long Gettotalram () {try {File file = new file ("/proc/meminfo"); FileInputStream fis = new FileInputStream (file); BufferedReader br = new BufferedReader (new InputStreamReader (FIS));//memtotal:253604 kbstring result = Br.readline (); StringBuffer sb = new StringBuffer () char[] chars = Result.tochararray (); for (char c:chars) {if (c >= ' 0 ' && C <= ' 9 ') {sB.append (c);}} Return Long.parselong (sb.tostring ()) * 1024;} catch (Exception e) {//TODO auto-generated catch Blocke.printstacktrace (); return 0;}}}
Android system process phone memory tool class