我在我的應用程序中有一個自動的錯誤報告工具,其中包含用於調試的有用信息。如何找出ROM提供者是誰?
我想包括的一件事是ROM提供者。特別是我想知道用戶是否正在運行自定義ROM,哪些版本號最好。
任何想法如何以編程方式檢索此信息?
---從金廷採取的措施(見下文)
public static String getReadableModVersion() {
String modVer = getSystemProperty(Constants.SYS_PROP_MOD_VERSION);
return (modVer == null || modVer.length() == 0 ? "Unknown" : modVer);
}
由此常數是這樣的:
public static final String SYS_PROP_MOD_VERSION = "ro.modversion";
這裏是getSystemProperty();
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(TAG, "Unable to read sysprop " + propName, ex);
return null;
}
finally
{
if(input != null)
{
try
{
input.close();
}
catch (IOException e)
{
Log.e(TAG, "Exception while closing InputStream", e);
}
}
}
return line;
}
任何有CM ROM的人都可以爲我運行這個嗎?
Btw。小心,這是GPL代碼。我爲人不能使用它。 任何更簡單或非GPL的方式?
我看了一下。 http://code.google.com/p/cyanogen-updater/source/browse/trunk/src/cmupdaterapp/utils/SysUtils.java#19 公共靜態字符串getReadableModVersion(){ 字符串modVer = getSystemProperty(常量。SYS_PROP_MOD_VERSION); return(modVer == null || modVer.length()== 0?「Unknown」:modVer); } 其中常量是這樣的: public static final String SYS_PROP_MOD_VERSION =「ro.modversion」; 你運行Cyanogen嗎?你能爲我執行並告訴我結果嗎? – 2009-10-10 11:56:32
評論中沒有格式?無論我把它放在頂部。 – 2009-10-10 12:08:40
是的,我確實有他的ROM運行版本,我的結果是「CyanogenMod-4.0.4」,但是當通過仿真器運行在官方SDK版本上時,我確實會得到「未知」。 'ro.modversion'設置在/system/build.prop的build.prop文件中 – 2009-10-10 14:39:55