【问题标题】:Calculate ping time android计算ping时间android
【发布时间】:2016-03-26 21:30:06
【问题描述】:

如何计算来自 android 的 IP 地址的延迟/ping 时间(毫秒)。

我想在我的应用中实现这一点。 我已经尝试了以下代码,但它没有输出任何内容

private void executeCommand() throws IOException {
    String pingResult="  ";

    Runtime r=Runtime.getRuntime();
    Process p=r.exec(new String[] {"ping", "-c 4", "www.google.com"});
    try {
        p.waitFor();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    BufferedReader in=new BufferedReader(new InputStreamReader(p.getInputStream()));
    String inputLine;
    Toast.makeText(getApplicationContext(), "Going loop", 1).show();
    while((inputLine=in.readLine())!=null)
    {
        pingResult+=inputLine;
    }
    Toast.makeText(getApplicationContext(),pingResult, 1).show();
    System.out.println(pingResult);
    in.close();
}

【问题讨论】:

    标签: java android latency


    【解决方案1】:

    使用 adb shell ping Click

    adb 没有 ping。 adb shell 没有 ping 通

    netstat

    【讨论】:

      猜你喜欢
      • 2012-04-30
      • 2016-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-16
      • 2014-07-30
      • 1970-01-01
      • 2021-12-02
      相关资源
      最近更新 更多