我試圖使Android上的應用程序,顯示設備的硬件規格,例如硬件規格:如何使Android上的應用程序,顯示設備
處理器:四核1.2GHz的
1 GB存儲器RAM
8 GB存儲
的Android 4.4版
會有人幫我找一個庫,允許我這樣做?
我試圖使Android上的應用程序,顯示設備的硬件規格,例如硬件規格:如何使Android上的應用程序,顯示設備
處理器:四核1.2GHz的
1 GB存儲器RAM
8 GB存儲
的Android 4.4版
會有人幫我找一個庫,允許我這樣做?
您可以使用此代碼
Log.i("ManuFacturer :", Build.MANUFACTURER);
Log.i("Board : ", Build.BOARD);
Log.i("Display : ", Build.DISPLAY);
更多信息,可以在從http://developer.android.com/reference/android/os/Build.html
我不知道圖書館然而,可以提取特定的硬件規格,Facebook的設備年級可以找到庫可以分類設備插入基於硬件規格「年」:
此外,你可以通過他們的代碼來檢測他們如何獲得信息,如最大頻率KHz:
public static int getCPUMaxFreqKHz() {
int maxFreq = DEVICEINFO_UNKNOWN;
try {
for (int i = 0; i < getNumberOfCPUCores(); i++) {
String filename =
"/sys/devices/system/cpu/cpu" + i + "/cpufreq/cpuinfo_max_freq";
File cpuInfoMaxFreqFile = new File(filename);
if (cpuInfoMaxFreqFile.exists()) {
byte[] buffer = new byte[128];
FileInputStream stream = new FileInputStream(cpuInfoMaxFreqFile);
try {
stream.read(buffer);
int endIndex = 0;
//Trim the first number out of the byte buffer.
while (Character.isDigit(buffer[endIndex]) && endIndex < buffer.length) {
endIndex++;
}
String str = new String(buffer, 0, endIndex);
Integer freqBound = Integer.parseInt(str);
if (freqBound > maxFreq) {
maxFreq = freqBound;
}
} catch (NumberFormatException e) {
//Fall through and use /proc/cpuinfo.
} finally {
stream.close();
}
}
}
if (maxFreq == DEVICEINFO_UNKNOWN) {
FileInputStream stream = new FileInputStream("/proc/cpuinfo");
try {
int freqBound = parseFileForValue("cpu MHz", stream);
freqBound *= 1000; //MHz -> kHz
if (freqBound > maxFreq) maxFreq = freqBound;
} finally {
stream.close();
}
}
} catch (IOException e) {
maxFreq = DEVICEINFO_UNKNOWN; //Fall through and return unknown.
}
return maxFreq;
}