android获取系统信息
连接手机,adb shell 进入 Android Shell 模式,输入 getprop 获取系统属性值
通过上面方法拿到属性名,然后通过下面方法获取到系统的属性值
/**
* 获取build.prop文件中的某个属性
*
* @param propName 属性名称
* @return 属性值
*/
public static String getSystemProperty(String propName) {
Log.i(LOG_TAG, "getSystemProperty in time: " + System.currentTimeMillis());
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 (Exception ex) {
Log.e(LOG_TAG, "Unable to read sysprop " + propName, ex);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (Exception e) {
Log.e(LOG_TAG, "Exception while closing InputStream", e);
}
}
}
Log.i(LOG_TAG, "getSystemProperty out time: " + System.currentTimeMillis());
return line;
}
posted on 2017-10-19 18:36 guangdeshishe 阅读(324) 评论(0) 编辑 收藏 举报