- 獲得手機root權限
adb shell
su
cd system
cat build.prop
可找到第三方rom系統(tǒng)的版本,比如ro.build.version.emui=EmotionUI_2.0
,這里我們需要的是第三方rom系統(tǒng)的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;
}
調(diào)用getSystemProperty("ro.build.version.emui")
即可獲得第三方rom系統(tǒng)版本號