예제 #1
0
        public void run() {
          long tx = networkInfo.getUidTxBytes();
          long rx = networkInfo.getUidRxBytes();
          txtTraffic.setText(
              String.format("流量 - tx: %s rx: %s total: %s bytes", tx, rx, (tx + rx)));

          cpuInfo.readCpuStat();
          txtCpu.setText(
              String.format(
                  "CPU - %.2f%% pid: %d uid: %d",
                  (float) cpuInfo.getProcessCPU() * 100 / cpuInfo.getTotalCPU(), cpuInfo.pid, uid));

          txtMem.setText(
              String.format(
                  "内存 - process: %dM free: %dM total: %dM",
                  memInfo.getPidMemorySize(MonitorService.this.getApplicationContext()),
                  memInfo.getFreeMemorySize(MonitorService.this.getApplicationContext()),
                  memInfo.getTotalMemory()));

          handler.postDelayed(this, 1000);
        }
예제 #2
0
 public void reset() {
   networkInfo.reset();
   cpuInfo.reset();
 }