【问题标题】:sencha touch + phonegap :: how to measure internet connection speed (3G-check) on iOS iPhonesencha touch + phonegap :: 如何在 iOS iPhone 上测量互联网连接速度(3G 检查)
【发布时间】:2012-02-01 14:54:12
【问题描述】:

有没有办法/解决方法来找出 iphone 设备与互联网的连接速度? 使用 phonegap,您只能测量是否有 2g/3G 连接或 wifi 连接(或无连接)。 但我想让我的应用找出是否只有缓慢的网络连接(2G/EDGE 和更小)。

【问题讨论】:

    标签: iphone ios cordova connection sencha-touch


    【解决方案1】:

    编写一个返回 1 MB 数据的 Web 服务。使用 Ext.ajax.request 调用 Ajax。同时也启动一个定时器。调用成功句柄时停止计时器。这将为您提供下载 1MB 数据所需的毫秒数。使用简单的数学计算连接速度。

    //start time here
    Ext.ajax.request({
        url: someurl_that_returns_1MB_of_data,
        method: GET,
        success: function (){
        //stop time here
        }
    });
    

    另见:how to count time

    【讨论】:

      【解决方案2】:

      如果您想知道设备的连接类型,您可以简单地使用 -

      navigator.network.connection.type
      

      http://docs.phonegap.com/en/1.4.1/phonegap_connection_connection.md.html#Connection

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-18
        • 1970-01-01
        • 2015-08-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多