Android设备信息

时间:2011-08-16 06:56:03

标签: android

是否有用于以编程方式提取有关当前Android设备的信息的API?例如,“model”,“OS”等属性

这将是iOS的UIDevice类和实例属性的类比。

3 个答案:

答案 0 :(得分:24)

试试这个:

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 :(得分:22)

您可以使用课程android.os.Build获取大部分设备信息。

例如:

String myDeviceModel = android.os.Build.MODEL;

答案 2 :(得分:3)

尝试这些家伙,我为你们所有人都非常轻松:

只需调用此方法: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