android获取系统信息

Posted guangdeshishe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

 

以上是关于android获取系统信息的主要内容,如果未能解决你的问题,请参考以下文章

在 android dumpsys 中获取当前可见片段的信息

错误记录Flutter 混合开发获取 BinaryMessenger 报错 ( FlutterActivityAndFragmentDelegate.getFlutterEngine() )(代码片段

在 Android 中获取基站信息

Android 使用两个不同的代码片段获取当前位置 NULL

python BrickstorOS片段用于获取各种文件系统信息。

如何从Android片段中的相机获取图像