in my application i need to find the speed of connected network (wifi/GPRS/3G). Here i need help to find the speed of GPRS/3G network. Can you please help me how to solve this problem.
4 Answers
TrafficStats will do the work. You can get bytes transferred, then you can calculate the speed.

- 3,699
- 10
- 42
- 68
This isn't a complete answer either, but for Wifi networks (not cellular), you can get the link rate through something like the following:
public String getLinkRate()
{
WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
WifiInfo wi = wm.getConnectionInfo();
return String.format("%d Mbps", wi.getLinkSpeed());
}
A few things to note:
- This will require the
android.permission.ACCESS_WIFI_STATE
permission. - It will always be one of the rates specified by the 802.11 standard (see the table here)
- It is only the rate that the handset and AP have negotiated as the maximum rate. A lot of factors come into play that affect the actual rate you'd get while, say surfing the web (e.g. wireless congestion and collisions, the upstream link rate)

- 29,432
- 3
- 65
- 92
maybe it is possible to figure out, that user is connected to wifi, gprs, or g3 network. Then you can figure out how fast is each technology. Also you can put file (for example 3MB) on fast connection server. Then you can download that file and measure time, how long it takes. Then just calculate... Or You can calculate it after each second while file is downloading.
Also download speed may vary from various conditions. Like network strength (booth wireless and mobile). For example, if user is connected to 54mbit wifi and access point is 60 meters form user, then download speed wont be even half of that. Here is example with download speed calculations java howto calculate Mbit/s during while loop download
-
you can also see this question http://stackoverflow.com/questions/8624828/how-to-know-upload-transfer-speed – Guntis Oct 18 '12 at 16:53
Have a look at Zwitscher's NetworkHelper class
Basically you need to obtain the ConnectivityManager
cManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
and then query this for what you want to know
NetworkInfo info = cManager.getActiveNetworkInfo();
int type = info.getType();
int subType = info.getSubtype();
For more info, browse the above class to see the meanings of type
and subType
.

- 30,426
- 13
- 82
- 119
-
Hi Heiko Rupp Thanks for answering. But here getType() returns the type of network connected(Wifi/mobile) and getSubType() returns subtypes of connected network if any. those are not useful to find mobile network speed. – VenkaReddy Apr 15 '11 at 08:02
-
This answer may be somewhat helpful in determining what the expected or maximum rate is (based on network type), but it is not at all helpful for determining what the current/available rate is. The variation in cellular data transmission rates is too high for this to be of much use if accuracy is a concern. – jedwards Mar 24 '12 at 01:54