Code example for ActivityManager

Methods: getMemoryInfo

0
	 */ 
	public long getFreeMemorySize(Context context) {
		ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo();
		ActivityManager am = (ActivityManager) context
				.getSystemService(Context.ACTIVITY_SERVICE);
		am.getMemoryInfo(outInfo);
		long avaliMem = outInfo.availMem;
		return avaliMem / 1024;
	} 
 
	/** 
	 * get the memory of process with certain pid. 
	 *  
	 * @param pid 
	 *            pid of process 
	 * @param context 
	 *            context of certain activity 
	 * @return memory usage of certain process 
	 */ 
	public int getPidMemorySize(int pid, Context context) {
		ActivityManager am = (ActivityManager) context