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
This is specilally to detect internet connection speed by facebook sdk
ConnectionQuality cq = ConnectionClassManager.getInstance().getCurrentBandwidthQuality();
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;
}
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.
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.