android获取ping IP的fps

p = Runtime.getRuntime().exec("ping -c 4 -w 20 " + serverIp);
int status = p.waitFor();
if (status == 0) {
    BufferedReader buf = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String str = new String();
    while ((str = buf.readLine()) != null) {
        if (str.contains("avg")) {
            int i = str.indexOf("/", 20);
            int j = str.indexOf(".", i);
            delay = str.substring(i + 1, j);
        }
    }
    Log.d("look_fps", delay);
}

你可能感兴趣的:(迎刃而解,ping,fps,延时)