【问题标题】:Measuring my app's network usage测量我的应用的网络使用情况
【发布时间】:2013-04-15 19:21:39
【问题描述】:

当然,我希望我的 android 应用程序的网络使用率尽可能低,问题是如何衡量它。 我设法用tcpdump捕获流量并在wireshark中打开它,这是要走的路吗? 我几乎不知道wireshark中的所有东西意味着什么,显然我必须阅读它,我只是想问一下是否有专门用于上述目的的教程或工具?

【问题讨论】:

标签: android wireshark


【解决方案1】:

Here你有关于测量网络使用情况的非常简单的教程。

你也可以下载this application尝试反编译看代码。

【讨论】:

    【解决方案2】:

    尝试使用TrafficStats统计系统流量。

    统计应用流量。如果您使用 HttpClient ,请尝试

    HttpGet httpRequest = new HttpGet("http://xx.com/*");
    HttpResponse response = httpClient.execute(httpRequest);
    HttpEntity entity = response.getEntity();
    int flowBytes = entity.getContentLength() ; //Traffic statistics
    

    如果你使用 URLConnection ,试试

    URLConnection conn = imageUri.toURL().openConnection();
    conn.setConnectTimeout(connectTimeout);
    conn.setReadTimeout(readTimeout);
    int flowBytes = conn.getContentLength() //Traffic statistics
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-06
      • 2012-10-29
      • 2018-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多