ActivityManager中包含的MemoryInfo是存储系统内存信息的封装类,我们可以掉用ActivityManager的getMemoryInfo(MemoryInfo outInfo)方法来获取系统的可用内存大小。
ActivityManager _ActivityManager = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo minfo = new ActivityManager.MemoryInfo(); _ActivityManager.getMemoryInfo(minfo); Log.i("tag", String.valueOf(minfo.availMem/(1024*1024))+"MB"); |
转自:http://hi.baidu.com/huaxinchang/blog/item/8e635e510a077e0f367abed4.html