当前位置: 代码迷 >> Android >> ActivityManager.MemoryInfo 小疑点
  详细解决方案

ActivityManager.MemoryInfo 小疑点

热度:37   发布时间:2016-04-28 07:06:00.0
ActivityManager.MemoryInfo 小问题
本帖最后由 yagamil 于 2013-10-29 22:11:24 编辑
小菜一个,请教一下函数提示说 totalMem 
totalMem cannot be resolved or is not a field
可能怀疑我用的sdk是旧的,我在google 文档看到的这个成员函数是在sdk18版本上看的

    public long getTotalAvaile()
    {
     long memTotal;
     ActivityManager am=(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
     ActivityManager.MemoryInfo mi=new ActivityManager.MemoryInfo();
     //MemoryInfo
     am.getMemoryInfo(mi);
     memTotal=mi.totalMem();
    
     return memTotal;
    }

------解决方案--------------------
totalMem是个域,不是方法,改成这样:
memTotal=mi.totalMem;