zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    熟悉常用的Linux操作
    Hadoop综合大作业
    理解MapReduce
    熟悉常用的Hbase操作
    第三章 熟悉常用的HDFS操作
    爬虫大作业
    数据结构化与保存
    爬取校园新闻首页的新闻
    网络爬虫基础练习
    综合练习:词频统计
  • 原文地址:https://www.cnblogs.com/agilezhu/p/7694133.html
Copyright © 2011-2022 走看看