how to get the android phone model, version, sdk details?

前端 未结 5 2026
感情败类
感情败类 2021-01-30 11:03

how to get the android phone model, version, sdk details?

相关标签:
5条回答
  • 2021-01-30 11:16

    First of all, have a look at these "Build" class at android-sdk page: 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;
    
    0 讨论(0)
  • 2021-01-30 11:16

    You can use Build.MODEL and Build.VERSION

    0 讨论(0)
  • 2021-01-30 11:16

    I recommend open library "Caffeine", This library contain get Device Name, or Model, have SD Card check, and many features.

    this library is here.

    https://github.com/ShakeJ/Android-Caffeine-library

    And you use 'SystemUtil' example,

    SystemUtil.modelName();
    
    0 讨论(0)
  • 2021-01-30 11:26

    // Getting Device Model,Manufacturer,android os version and device 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;
    }
    
    0 讨论(0)
  • 2021-01-30 11:40
     String s = "Debug-info:";
     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 + ")";
    

    Example output:

     OS Version: 4.9.106-perf+(1909112330)
     OS API Level: 9(28)
     Device: OnePlus6
     Model (and Product): ONEPLUS A6000 (OnePlus6)
    
    0 讨论(0)
提交回复
热议问题