判断小米miui版本

miui版本读取靠的是getprop

ro.miui.ui.version.name V125
ro.miui.version.code_time 版本时间10位时间戳

public static String checkMIUI() {
    String versionCode = "";
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    LogUtils.i("Build.MANUFACTURER = " + manufacturer + " ,Build.MODEL = " + Build.MODEL);
    if (!TextUtils.isEmpty(manufacturer) && manufacturer.equals("Xiaomi")) {
        versionCode = getSystemProperty("ro.miui.version.code_time");
    }
    return versionCode;
}

public static String getSystemProperty(String propName) {
    String line;
    BufferedReader input = null;
    try {
        Process p = Runtime.getRuntime().exec("getprop " + propName);
        input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
        line = input.readLine();
        input.close();
    } catch (IOException ex) {
        LogUtils.i("Unable to read sysprop " + propName, ex);
        return null;
    }
    finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
                LogUtils.i("Exception while closing InputStream", e);
            }
        }
    }
    return line;
}

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注