如何获得android手机型号,版本,sdk细节?
如何获得android手机型号,版本,sdk细节?
首先,在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;
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.RELEASE + "("+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 + ")";
你可以使用Build.MODEL和Build.VERSION
//获取设备型号,制造商,Android操作系统版本和设备ID:
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; }
我build议打开库“咖啡因”,这个库包含获取设备名称或型号,有SD卡检查,和许多function。
这个图书馆在这里。
https://github.com/ShakeJ/Android-Caffeine-library
而你使用'SystemUtil'的例子,
SystemUtil.modelName();