美文网首页
如何在代码中对第三方rom系统的版本进行逻辑判断

如何在代码中对第三方rom系统的版本进行逻辑判断

作者: deagle | 来源:发表于2014-08-06 20:04 被阅读395次
  • 获得手机root权限

adb shell

su

cd system

cat build.prop

可找到第三方rom系统的版本,比如ro.build.version.emui=EmotionUI_2.0,这里我们需要的是第三方rom系统的key,如例子中的ro.build.version.emui.

  • 如何在代码中获得版本呢?即要获得EmotionUI_2.0.参考参考Android源码:
   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) {
            Log.e("dingyi", "Unable to read sysprop " + propName, ex);
            return null;
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    Log.e("dingyi", "Exception while closing InputStream", e);
                }
            }
        }
        return line;
    }

调用getSystemProperty("ro.build.version.emui")即可获得第三方rom系统版本号

相关文章

网友评论

      本文标题:如何在代码中对第三方rom系统的版本进行逻辑判断

      本文链接:https://www.haomeiwen.com/subject/tiketttx.html