Android学习点点滴滴之获取系统可用内存
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");