怎麼用代碼判斷Android手機的Rom是MIUI及獲取MIUI版本

轉載:

http://blog.csdn.net/devilkin64/article/details/19415717

參考源碼

https://code.google.com/p/cyanogen-updater/source/browse/trunk/src/cmupdaterapp/utils/SysUtils.java


在Android shell模式下輸入 getprop 就能獲取系統屬性值

如果Rom是miUI那麼就會有以下字段.

[ro.miui.ui.version.code]: [3]
[ro.miui.ui.version.name]: [V5] 

	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) {
			return null;
		} finally {
			if (input != null) {
				try {
					input.close();
				} catch (IOException e) {
				}
			}
		}
		return line;
	}

	public static boolean isMIUIRom(){
		String property = BaseUtils.getSystemProperty("ro.miui.ui.version.name");
		return !TextUtils.isEmpty(property);
	}


發佈了43 篇原創文章 · 獲贊 3 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章