各位朋友过得怎么样,希望大家多多指教。朋友们我想知道我的 android 设备有多少内存以及使用了多少内存活动内存、非活动内存、空闲内存和有线内存(以 MB 为单位)我已经通过这个链接通过解析“/system/bin/”来说明这一点cat", "/proc/meminfo" 我们可以得到我上面提到的东西,是的,我得到了所有的东西,但是我得到了一个长字符串,我拥有一切
MemTotal: 377192 kB
MemFree: 10448 kB
Buffers: 1368 kB``
Cached: 74276 kB
SwapCached: 0 kB
Active: 143116 kB
Inactive: 177292 kB
Active(anon): 118388 kB
Inactive(anon): 137664 kB
Active(file): 24728 kB
Inactive(file): 39628 kB
Unevictable: 10664 kB
Mlocked: 10372 kB
HighTotal: 190464 kB
HighFree: 568 kB
LowTotal: 186728 kB
LowFree: 9880 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 8 kB
Writeback: 0 kB
AnonPages: 255440 kB
Mapped: 45816 kB
Shmem: 624 kB
Slab: 10952 kB
SReclaimable: 2456 kB
SUnreclaim: 8496 kB
我从中得到的甚至更大的字符串
private String ReadCPUinfo()
{
ProcessBuilder cmd;
StringBuffer strMemory = new StringBuffer();
//final ActivityManager activityManager =(ActivityManager)
context.getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager actvityManager = (ActivityManager) this.getSystemService(
ACTIVITY_SERVICE );
ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo ();
actvityManager.getMemoryInfo( mInfo );
strMemory.append("Available Memory : ");
strMemory.append(mInfo.availMem/1048576L);
strMemory.append("\n");
strMemory.append("\n");
String result=strMemory.toString();
try{
String[] args = {"/system/bin/cat", "/proc/meminfo"};
cmd = new ProcessBuilder(args);
Process process = cmd.start();
InputStream in = process.getInputStream();
byte[] re = new byte[1024];
while(in.read(re) != -1){
System.out.println("itthhe ==== --- >>>> "+new String(re));
result = result + new String(re);
}
in.close();
} catch(IOException ex){
ex.printStackTrace();
}
return result;
}
我想知道我是否可以动态地打破这个字符串以获得差异。设备或是否有任何其他方法可以找到上述内容
我也经历过这个,但也不是完全使用..我很容易获得可用的内存信息,但我需要全部四个
任何帮助都非常感谢提前感谢