Android examples for Hardware:Memory
get Target Heap Utilization
//package com.java2s; import java.lang.reflect.Method; public class Main { public static float getTargetHeapUtilization() { try {/*w ww .j a v a 2 s . c o m*/ Class VMRuntimeClass = Class.forName("dalvik.system.VMRuntime"); Method getRuntimeMethod = VMRuntimeClass.getMethod( "getRuntime", new Class[0]); Class[] arrayOfClass = new Class[1]; arrayOfClass[0] = Long.TYPE; Method getTargetHeapUtilization = VMRuntimeClass.getMethod( "getTargetHeapUtilization", new Class[0]); Object runtimeObject = getRuntimeMethod.invoke(null, new Object[0]); Float ret = (Float) getTargetHeapUtilization.invoke( runtimeObject, new Object[0]); android.util.Log.e("BAIDUMAP_PERFM", "getTargetHeapUtilization:" + ret.floatValue()); return ret.floatValue(); } catch (Throwable localThrowable) { localThrowable.printStackTrace(); } return 0; } }