以编程方式查找Android系统信息 [英] Programmatically find Android system info
问题描述
我正在尝试以编程方式查找Android设备的系统信息,具体为:
I am trying to programatically find the system info for Android devices, specifically:
- RAM
- CPU速度
- #cores,architecture等。
是否有任何Android类指定此信息。我一直在使用android.board库,但它似乎没有我想要的一切。
Are there any Android classes that specify this information. I have been using the android.board library, but it doesn't seem to have everything that I want.
推荐答案
让我告诉你我做了什么,所以访问这个帖子的其他人可以了解一下步骤:
Let me tell you what I did, So others who visit this thread can come to know the steps:
1)parse / proc / meminfo命令。你可以在这里找到参考代码:
获取Android中的内存使用情况
2)使用以下代码获取当前内存:
1) parse /proc/meminfo command. You can find reference code here: Get Memory Usage in Android 2) use below code and get current RAM:
MemoryInfo mi = new MemoryInfo();
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
activityManager.getMemoryInfo(mi);
long availableMegs = mi.availMem / 1048576L;
注意:请注意 - 我们只需计算一次总内存。所以在你的代码中只调用一次点1然后,你可以重复调用第2点的代码。
Note: please note that - we need to calculate total memory only once. so call point 1 only once in your code and then after, you can call code of point 2 repetitively.
这篇关于以编程方式查找Android系统信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!