我正在开发和Android应用程序,我需要以编程方式知道手机的miui版本信息.有人知道怎么做吗?在android.os.build和android.os.build.version中,rom名称只是关于生产者的版本和一些东西.我需要知道哪个是安装的rom,例如:xiaomi.eu stable或weekly,china developer或global stable等...当我点击"phone"时,我可以从手机设置中读取相同的信息信息".
您必须使用反射来读取 MIUI 版本名称和版本代码。
MIUI 版本代码和版本名称可以通过读取ro.miui.ui.version.code和ro.miui.ui.version.name属性来包含
private void readMIVersion() {
try {
@SuppressLint("PrivateApi") final Class<?> propertyClass = Class.forName("android.os.SystemProperties");
final Method method = propertyClass.getMethod("get", String.class);
final String versionCode = (String) method.invoke(propertyClass, "ro.miui.ui.version.code");
final String versionName = (String) method.invoke(propertyClass, "ro.miui.ui.version.name");
Log.d(TAG, "Version Code: " + versionCode);
Log.d(TAG, "Version Name: " + versionName);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
目前,您可以阅读这些信息,但在未来的版本中,可能会删除读取这些受限值的功能。
小智 5
只需使用Build.VERSION.INCREMENTAL. 就我而言,它返回"V12.5.1.0.RJOEUXM".
此外,您不仅可以从此字符串中提取 MIUI 版本。
参见https://www.xiaomist.com/2020/08/what-do-letters-and-numbers-that.html
| 归档时间: |
|
| 查看次数: |
269 次 |
| 最近记录: |