码迷,mamicode.com
首页 > 移动开发 > 详细

android获取系统信息

时间:2017-10-19 19:56:21      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:osi   alt   ram   close   adb shell   while   nbsp   line   buffered   

连接手机,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;
}

 

android获取系统信息

标签:osi   alt   ram   close   adb shell   while   nbsp   line   buffered   

原文地址:http://www.cnblogs.com/agilezhu/p/7694133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!