红米1最新android版本号,判断MIUI版本及版本号

识别是否是MIUI

根据MIUI开发者文档中的提示

请使用android.os.Build对象,查询MANUFACTURER和MODEL的值,MANUFACTURER值为[Xiaomi]即为小米设备,MODEL为设备名称,比如[Redmi 4X]表示红米4X。

其实读的属性是

[ro.product.manufacturer]: [Xiaomi]

[ro.product.model]: [Redmi 4X]

识别版本号

然后在adb shell 之后getprop可以得到一个属性『ro.miui.version.code_time』,这个属性是一个毫秒值,对应的是MIUI开发版的版本号,比如我的MIUI9开发版7.8.10对应的:

[ro.miui.ui.version.name]: [V9]

表示版本号为 MIUI9

[ro.miui.version.code_time]: [1502294400]

1502294400毫秒值转换为时间:2017/8/10,表示版本为7.8.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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值