2011-08-16 133 views
11

是否有API用於以編程方式提取有關當前Android設備的信息?例如,像「模型」,「OS」等特性Android設備信息

這將是iOS版的類和實例屬性的類似物。

+0

Build.SERIAL可以試試這個。 – kumar

+0

[如何檢測系統信息如os或設備類型]的可能重複(http://stackoverflow.com/questions/3213205/how-to-detect-system-information-like-os-or-device-type) –

回答

21

可以使用類android.os.Build得到大多數的設備信息。

例如:

String myDeviceModel = android.os.Build.MODEL; 
+0

我可以用它來提取操作系統的版本(例如「Android 2.2」)嗎? – SK9

+0

對於您可以使用:http://developer.android.com/reference/android/os/Build.VERSION.html – roundhill

23

試試這個:

String _OSVERSION = System.getProperty("os.version"); 
String _RELEASE = android.os.Build.VERSION.RELEASE; 
String _DEVICE = android.os.Build.DEVICE; 
String _MODEL = android.os.Build.MODEL; 
String _PRODUCT = android.os.Build.PRODUCT; 
String _BRAND = android.os.Build.BRAND; 
String _DISPLAY = android.os.Build.DISPLAY; 
String _CPU_ABI = android.os.Build.CPU_ABI; 
String _CPU_ABI2 = android.os.Build.CPU_ABI2; 
String _UNKNOWN = android.os.Build.UNKNOWN; 
String _HARDWARE = android.os.Build.HARDWARE; 
String _ID = android.os.Build.ID; 
String _MANUFACTURER = android.os.Build.MANUFACTURER; 
String _SERIAL = android.os.Build.SERIAL; 
String _USER = android.os.Build.USER; 
String _HOST = android.os.Build.HOST; 

更多信息以http://developer.android.com/reference/android/os/Build.html

+1

System.getProperty( 「os.version」)返回Linux版本不是Android操作系統版本 – Karioki

+1

@ arjun_9990誰說會呢? –

+0

我誤將它作爲android版本,所以其他人也可能。對不起,沒有正確的方式。 – Karioki

2

試試這個傢伙,我做了超級容易讓你所有:

剛調用此方法:getDeviceSuperInfo();

private void getDeviceSuperInfo() { 
    Log.i(TAG, "getDeviceSuperInfo"); 

    try { 

     String s = "Debug-infos:"; 
     s += "\n OS Version: "  + System.getProperty("os.version")  + "(" + android.os.Build.VERSION.INCREMENTAL + ")"; 
     s += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT; 
     s += "\n Device: "   + android.os.Build.DEVICE; 
     s += "\n Model (and Product): " + android.os.Build.MODEL   + " ("+ android.os.Build.PRODUCT + ")"; 

     s += "\n RELEASE: "   + android.os.Build.VERSION.RELEASE; 
     s += "\n BRAND: "   + android.os.Build.BRAND; 
     s += "\n DISPLAY: "   + android.os.Build.DISPLAY; 
     s += "\n CPU_ABI: "   + android.os.Build.CPU_ABI; 
     s += "\n CPU_ABI2: "  + android.os.Build.CPU_ABI2; 
     s += "\n UNKNOWN: "   + android.os.Build.UNKNOWN; 
     s += "\n HARDWARE: "  + android.os.Build.HARDWARE; 
     s += "\n Build ID: "  + android.os.Build.ID; 
     s += "\n MANUFACTURER: " + android.os.Build.MANUFACTURER; 
     s += "\n SERIAL: "   + android.os.Build.SERIAL; 
     s += "\n USER: "   + android.os.Build.USER; 
     s += "\n HOST: "   + android.os.Build.HOST; 


     Log.i(TAG + " | Device Info > ", s); 

    } catch (Exception e) { 
     Log.e(TAG, "Error getting Device INFO"); 
    } 

}//end getDeviceSuperInfo 
+1

這是使用StringBuilder/StringBuffer的最佳例子:) –