Android 如何获取安卓手机型号、版本、sdk 详细信息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3596722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:54:34  来源:igfitidea点击:

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

android

提问by jaks

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

如何获取安卓手机型号、版本、sdk 详细信息?

回答by Paresh Mayani

First of all, have a look at these "Build" class at android-sdk page: http://developer.android.com/reference/android/os/Build.html.

首先,在 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;

回答by Ajay

 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)

回答by Megha Joshi - GoogleTV DevRel

You can use Build.MODELand Build.VERSION

您可以使用Build.MODELBuild.VERSION

回答by Brijesh Patel

// Getting Device Model,Manufacturer,android os version and device id:

// 获取设备型号、制造商、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;
}

回答by ShakeJ

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

我推荐开放库“Caffeine”,该库包含获取设备名称或型号,具有 SD 卡检查和许多功能。

this library is here.

这个图书馆在这里。

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

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

And you use 'SystemUtil' example,

你使用'SystemUtil'的例子,

SystemUtil.modelName();