我如何在android中以编程方式了解我的下载和上传速度

时间:2014-05-22 13:45:15

标签: android networking wifi android-wifi 3g

我想开发一个应用程序,告诉我我的下载和上传速度以及网络名称是3G,4G,WIFI等。 像Speed Test.net一样开发相同的appilcation想法

提前致谢。

3 个答案:

答案 0 :(得分:3)

可能是这个JSpeedTest library有用吗

答案 1 :(得分:1)

避免在静态实例中调用 -

127.0.0.1 - - [08/May/2016 10:37:29] "GET /accounts HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/eve/flaskapp.py", line 946, in __call__
    return super(Eve, self).__call__(environ, start_response)
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.5/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/python3.5/site-packages/eve/endpoints.py", line 54, in collections_endpoint
    response = get(resource, lookup)
  File "/usr/lib/python3.5/site-packages/eve/methods/common.py", line 242, in rate_limited
    return f(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/eve/auth.py", line 79, in decorated
    return f(*args, **kwargs)
  File "/usr/lib/python3.5/site-packages/eve/methods/common.py", line 944, in decorated
    r = f(resource, **combined_args)
  File "/usr/lib/python3.5/site-packages/eve/methods/get.py", line 92, in get
    req = parse_request(resource)
  File "/usr/lib/python3.5/site-packages/eve/utils.py", line 155, in parse_request
    r.if_modified_since = weak_date(headers.get('If-Modified-Since'))
  File "/usr/lib/python3.5/site-packages/eve/utils.py", line 174, in weak_date
    timedelta(seconds=1) if date else None
  File "/usr/lib/python3.5/_strptime.py", line 500, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/lib/python3.5/_strptime.py", line 340, in _strptime
    data_string[found.end():])
ValueError: unconverted data remains: +00:00

答案 2 :(得分:0)

尝试以下代码: -

WifiManager wifiManager = Context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null) {
    Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured using WifiInfo.LINK_SPEED_UNITS
}

见以下链接: -

https://stackoverflow.com/questions/8252656/how-to-get-download-speed-in-android-device-or-mobile

下面是演示代码: -

http://www.gregbugaj.com/?p=47