开发者

Android device information

Is there an API for programmatically extracting information regarding the current Android device? For开发者_运维问答 example, properties like "model", "OS" etc.

This would be an analogue of iOS's UIDevice class and instance properties.


Try This:

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;

More info at http://developer.android.com/reference/android/os/Build.html


You can use the class android.os.Build to get most of the device information.

For example:

String myDeviceModel = android.os.Build.MODEL;


Try this guys, I made it super easy for you all:

just call this method : 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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜