Calculating Internet Speed in android

前端 未结 4 645
遥遥无期
遥遥无期 2020-12-08 22:32

I am working with an App which contains web service things.

In that I need to know the status when the Internet speed is low. How to find the internet speed level in

相关标签:
4条回答
  • 2020-12-08 22:50

    This is specilally to detect internet connection speed by facebook sdk

    ConnectionQuality cq = ConnectionClassManager.getInstance().getCurrentBandwidthQuality();
    
    0 讨论(0)
  • 2020-12-08 23:03

    This is the code for getting speed of your internet while connected to wifi.

    WifiManager wifiManager = (WifiManager) 
        this.getSystemService(Context.WIFI_SERVICE);
    
    List<ScanResult> wifiList = wifiManager.getScanResults();
    for (ScanResult scanResult : wifiList) {
        int level = WifiManager.calculateSignalLevel(scanResult.level, 5);
        String net=String.valueOf(level);
       // Toast.makeText(MainActivity.this,net,Toast.LENGTH_LONG).show();
    
    }
    
    // Level of current connection.here rssi is the value of internet speed whose value
    // can be -50,-60 and some others,you can find the speed values easily on internet.
    
    int rssi = wifiManager.getConnectionInfo().getRssi();
    int level = WifiManager.calculateSignalLevel(rssi, 5);
    String net=String.valueOf(rssi);
    Toast.makeText(MainActivity.this,net,Toast.LENGTH_LONG).show();
    
    // -100 is the minimum speed value of your internet.
    if(rssi < -100) {
        slowInternet=false;
    }
    
    0 讨论(0)
  • 2020-12-08 23:05

    If you are connected to WiFi you can find the speed of the connection using WifiManager :

    WifiInfo wifiInfo = wifiManger.getConnectionInfo();
    

    and then from the WifiInfo you can get the current speed :

    int speedMbps = wifiInfo.getLinkSpeed();
    

    If you are on 3G, I don't think there is a standard way of finding out, maybe you can assume automatically that 3G is slow.

    0 讨论(0)
  • 2020-12-08 23:05

    There is no stable solution for this but I found this App source code which might helps you in order to get the Internet speed.

    0 讨论(0)
提交回复
热议问题