zoukankan      html  css  js  c++  java
  • Android代码执行adb shell top命令读取结果

    new Thread() {
    @Override
    public void run() {
    StringBuilder tv = new StringBuilder();
    int rate = 0;
    try {
    String Result;
    Process p;
    p = Runtime.getRuntime().exec("top -n 1");
    InputStream in = p.getInputStream();
    if (android.os.Build.VERSION.SDK_INT >= 26) {
    LogUtil.i("cpu", "Result Android8.0+ ");
    byte[] re = new byte[1024];
    while (in.read(re) != -1) {
    tv = tv.append(new String(re));
    }
    LogUtil.i("cpu", "Result Android8.0+ tv " + tv.toString());
    } else {
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    while ((Result = br.readLine()) != null) {
    if (Result.trim().length() < 1) {
    continue;
    } else {
    LogUtil.i("cpu", "Result " + Result.toString());
    break;
    }
    }
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }.start();
  • 相关阅读:
    购物网站被p.egou.com强制恶意劫持
    css下拉菜单
    StringToInt
    JframeMaxSize
    frameMaxSize
    inputChar
    英语要求
    sciAndSubject
    fileRename
    tensorflowOnWindows
  • 原文地址:https://www.cnblogs.com/mengdao/p/15103106.html
Copyright © 2011-2022 走看看