运行内存、可用内存获取

//total ram
	public int f()
	  {
	    int i1 = 0;
	    int i2;
	    try
	    {
	      String[] arrayOfString = new java.io.RandomAccessFile("/proc/meminfo", "r").readLine().split(" kB")[0].split(" ");
	      i1 = Integer.parseInt(arrayOfString[(-1 + arrayOfString.length)]);
	      int i3 = Math.round(i1 / 1024);
	      return i3;
	    }
	    catch (IOException localIOException)
	    {
	      i2 = i1;
	      localIOException.printStackTrace();
	    }
	    return i2;
	  }


//Available RAM
	public int b(Context paramContext)
	{
	    ActivityManager localActivityManager = (ActivityManager)paramContext.getSystemService("activity");
	    ActivityManager.MemoryInfo localMemoryInfo = new ActivityManager.MemoryInfo();
	    localActivityManager.getMemoryInfo(localMemoryInfo);
	    return (int)(localMemoryInfo.availMem / 1024L / 1024L);
	}


posted @ 2017-02-10 16:49  稻香鱼  阅读(137)  评论(0)    收藏  举报