2017-08-21 56 views

回答

2

我在github上發現了一個旨在做到這一點的要點,試圖獲取「ro.miui.ui.version.name」系統屬性。

public static boolean isMiUi() { 
    return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name")); 
} 

public static String getSystemProperty(String propName) { 
    String line; 
    BufferedReader input = null; 
    try { 
     java.lang.Process p = Runtime.getRuntime().exec("getprop " + propName); 
     input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024); 
     line = input.readLine(); 
     input.close(); 
    } catch (IOException ex) { 
     return null; 
    } finally { 
     if (input != null) { 
      try { 
       input.close(); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 
     } 
    } 
    return line; 
} 

Origin on github

相關問題