任何人都可以幫助我如何通過代碼獲取Android設備的處理器名稱,速度和RAM。如何在Android設備中獲取處理器速度和RAM
4
A
回答
4
其唯一可能在根設備上或您的應用程序作爲系統應用程序運行。
對於想要的信息,你必須看看正在運行的內核,因爲我知道這個信息 不能被android系統本身獲得。
要獲取信息有關的CPU,你可以閱讀和分析此文件: 的/ proc/cpuinfo中
爲了獲得內存的信息,你可以閱讀和分析此文件: 的/ proc /內存
19
您可以獲得像我們通常在Linux中獲得的處理器,RAM和其他硬件相關的信息。 從終端我們可以在普通的Linux系統中發出這些命令。您不需要需要有一個根源設備爲此。
$ cat /proc/cpuinfo
同樣,您可以在android代碼中發出這些命令並獲得結果。
public void getCpuInfo() {
try {
Process proc = Runtime.getRuntime().exec("cat /proc/cpuinfo");
InputStream is = proc.getInputStream();
TextView tv = (TextView)findViewById(R.id.tvcmd);
tv.setText(getStringFromInputStream(is));
}
catch (IOException e) {
Log.e(TAG, "------ getCpuInfo " + e.getMessage());
}
}
public void getMemoryInfo() {
try {
Process proc = Runtime.getRuntime().exec("cat /proc/meminfo");
InputStream is = proc.getInputStream();
TextView tv = (TextView)findViewById(R.id.tvcmd);
tv.setText(getStringFromInputStream(is));
}
catch (IOException e) {
Log.e(TAG, "------ getMemoryInfo " + e.getMessage());
}
}
private static String getStringFromInputStream(InputStream is) {
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
try {
while((line = br.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
}
catch (IOException e) {
Log.e(TAG, "------ getStringFromInputStream " + e.getMessage());
}
finally {
if(br != null) {
try {
br.close();
}
catch (IOException e) {
Log.e(TAG, "------ getStringFromInputStream " + e.getMessage());
}
}
}
return sb.toString();
}
+1
工程像黃油 – Sandeep 2013-10-27 10:34:54
相關問題
- 1. 如何獲得Ram速度?
- 2. 如何獲取設備規格(ram - storage - cpu)庫或api Android
- 3. Android如何在設備中獲得全部內存RAM?
- 4. 如何從移動設備獲取經度和緯度Android
- 5. 如何確定Android設備的速度?
- 6. 如何在Android中獲取設備ID?
- 7. 獲取設備移動的速度
- 8. 如何在Android(仿真器/設備)中處理HOME按鈕
- 9. 如何在android中獲取設備的溫度
- 10. 如何獲取Android設備使用包管理器的功能
- 11. 如何管理Android設備亮度
- 12. 如何在gwt設備中獲得移動速度?
- 13. 如何獲取WP7中仿真器設備的當前經度和緯度值?
- 14. show處理器速度
- 15. 我如何獲得我的Android設備的經度和緯度
- 16. android gps設備獲取緯度和經度所用的時間
- 17. 如何在Android中獲得Interent速度?
- 18. 6502處理器如何在ROM和RAM之間傳輸數據?
- 19. 如何在Netty中處理讀取速度慢的讀者?
- 20. win32 api函數獲取處理器的當前速度
- 21. 如何從我的android設備獲取當前的經度和緯度
- 22. 如何在Android中獲取GPS中最準確的速度
- 23. Android(獲取當前速度)
- 24. 如何將android移植到ARM9處理器上的設備?
- 25. 如何從android設備獲取LENS_FOCUS_DISTANCE
- 26. 如何從Android設備獲取錯誤?
- 27. 如何獲取android設備ID?
- 28. C#速記獲取器和設置器
- 29. 如何獲取Android設備鈴聲的幅度值
- 30. 在C#中獲取設備的CPU利用率和WinCE上的可用RAM
這有幫助嗎? http://stackoverflow.com/questions/4875415/how-to-detect-android-cpu-speed – 2012-02-20 14:30:59
http://stackoverflow.com/questions/2201112/retrieving-device-information-on-android – 2012-02-20 14:32:57