What is the easiest way to check the network speed in android on both mobile and wifi connection? Is there a better solution than downloading a file from the network and doing some calculations manually on the basis of that.
Asked
Active
Viewed 528 times
1
-
I think you grossly underestimate how complex this topic is and how difficult it is to get numbers which actually mean something. (Spoiler: Most of the time those measured numbers don't mean anything) – Xaver Kapeller Jun 12 '15 at 09:43
1 Answers
1
You can check that whether internet connectivity is available on WiFi or not. If it is unavailable on WiFi then you can ask user to disable WiFi or change WiFi settings.
Another approach is that you manually get signal strength for WiFi and Mobile Network:
To get WiFi's signal strength:
WifiManager wifiManager = (WifiManager) this
.getSystemService(Context.WIFI_SERVICE);
int wifiSpeed = wifiManager.getConnectionInfo().getRssi();
Log.d("SignalStrength", "wifi" + wifiSpeed);
To get Mobile's signal strength:
MyPhoneStateListener MyListener = new MyPhoneStateListener();
TelephonyManager Tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
And make a listener for Signal strength change:
private class MyPhoneStateListener extends PhoneStateListener {
/*
* Get the Signal strength from the provider, each time there is an
* update
*/
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
Log.d("SignalStrength", "GSM" + String.valueOf(signalStrength
.getGsmSignalStrength());
}
};
You can get updated signal value and put it in Shared Preference then can compare it with WiFi signal value.
WiFi signal value range from -100 to 0.
0 means good strength and -100 means weak.
Mobile signal strength value is from (0-31,99).
0 means low and 31 means good.
99 not known or not detectable.

kumar kundan
- 2,027
- 1
- 27
- 41

Ashish Vora
- 571
- 1
- 8
- 27
-
Thank you so much for your reply, it can be helpful. But sometimes when connection speed is really slow even when there is a perfect signal strengh is what i am trying to solve. The search still continues. Thanks anyways :) – Asif Altaf Jun 16 '15 at 10:34
-
You can get speed by this way: http://stackoverflow.com/questions/19154992/getting-data-speed-of-wifi-mobile-network-programatically – Ashish Vora Jun 16 '15 at 11:14