我的应用程序中有一个自动错误报告工具,其中包含有用的调试信息.
我想要包括的一件事是ROM提供商.特别是我想知道用户是否正在运行自定义ROM,最好是使用版本号.
知道如何以编程方式检索此信息吗?
---取自Quintin(见下文)
public static String getReadableModVersion() {
String modVer = getSystemProperty(Constants.SYS_PROP_MOD_VERSION);
return (modVer == null || modVer.length() == 0 ? "Unknown" : modVer);
}
Run Code Online (Sandbox Code Playgroud)
这个常数是这样的:
public static final String SYS_PROP_MOD_VERSION = "ro.modversion";
Run Code Online (Sandbox Code Playgroud)
这是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, …Run Code Online (Sandbox Code Playgroud) android ×1