Android - 这有可能获得Android设备的系统配置吗?

时间:2014-05-16 16:04:34

标签: android

我想获取设备的系统配置信息,包括RAM,ROM,外部存储器,运行我的应用程序的处理器详细信息。 我是个乞丐,你能帮忙开始吗?

2 个答案:

答案 0 :(得分:1)

首先,在android-sdk页面上查看这些“Build”类:http://developer.android.com/reference/android/os/Build.html

// Device model
String PhoneModel = android.os.Build.MODEL;

// Android version
String AndroidVersion = android.os.Build.VERSION.RELEASE;

例如:

public String getDeviceName() {

    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;

    if (model.startsWith(manufacturer)) {
        return capitalize(model);
    } else {
        return capitalize(manufacturer) + " " + model;
    }
}

private String getAndroidVersion() {
    return android.os.Build.VERSION.RELEASE;
}

private String capitalize(String s) {
    if (s == null || s.length() == 0) {
        return "";
    }
    char first = s.charAt(0);
    if (Character.isUpperCase(first)) {
        return s;
    } else {
        return Character.toUpperCase(first) + s.substring(1);
    }
}

private String getDeviceId() {
    String deviceId = "";
    final TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    if (mTelephony.getDeviceId() != null) {
        deviceId = mTelephony.getDeviceId();
    } else {
        deviceId = Secure.getString(getApplicationContext()
                .getContentResolver(), Secure.ANDROID_ID);
    }
    return deviceId;
}

答案 1 :(得分:0)

Build类应包含您需要的所有信息。查看here

Nested Classes
class   Build.VERSION   Various version strings. 
class   Build.VERSION_CODES Enumeration of the currently known SDK version codes. 
Constants
String  UNKNOWN Value used for when a build property is unknown.
Fields
public static final String  BOARD   The name of the underlying board, like "goldfish".
public static final String  BOOTLOADER  The system bootloader version number.
public static final String  BRAND   The consumer-visible brand with which the product/hardware will be associated, if any.
public static final String  CPU_ABI The name of the instruction set (CPU type + ABI convention) of native code.
public static final String  CPU_ABI2    The name of the second instruction set (CPU type + ABI convention) of native code.
public static final String  DEVICE  The name of the industrial design.
public static final String  DISPLAY A build ID string meant for displaying to the user
public static final String  FINGERPRINT A string that uniquely identifies this build.
public static final String  HARDWARE    The name of the hardware (from the kernel command line or /proc).
public static final String  HOST    
public static final String  ID  Either a changelist number, or a label like "M4-rc20".
public static final String  MANUFACTURER    The manufacturer of the product/hardware.
public static final String  MODEL   The end-user-visible name for the end product.
public static final String  PRODUCT The name of the overall product.
public static final String  RADIO    This field was deprecated in API level 14. The radio firmware version is frequently not available when this class is initialized, leading to a blank or "unknown" value for this string. Use getRadioVersion() instead.
public static final String  SERIAL  A hardware serial number, if available.
public static final String  TAGS    Comma-separated tags describing the build, like "unsigned,debug".
public static final long    TIME    
public static final String  TYPE    The type of build, like "user" or "eng".
public static final String  USER    

使用Build.*获取所需信息。