How to find the data transfer speed on a GPRS / 3G network in Android?

in my application I need to find the speed of the connected network (Wi-Fi / GPRS / 3G). Here I need help to find the GPRS / 3G network speed. Could you help me solve this problem.

+4
source share
4 answers

This is also not a complete answer, but for Wi-Fi networks (not cellular), you can get the transfer speed 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 notes:

  • This will require the permission android.permission.ACCESS_WIFI_STATE .
  • This will always be one of the tariffs specified by the 802.11 standard (see table here )
  • Only the speed at which the handset and access point are matched as maximum speed. Many factors come into play that affect the actual speed that you get, say, surfing the Internet (for example, wireless congestion and collisions, uplink speed).
+1
source

TrafficStats will do the job. You can get the transmitted bytes, then you can calculate the speed.

+1
source

perhaps you can find out that the user is connected to a Wi-Fi network, gprs or g3. Then you can understand how fast each technology is. You can also put the file (for example, 3 MB) on the quick connection server. Then you can download this file and measure the time, how long it takes. Then just calculate ... Or you can calculate it after every second while the file is loading.

Also, the download speed may vary depending on various conditions. Like the power of the network (wireless and mobile phone). For example, if the user is connected to 54-bit Wi-Fi and the access point is 60 meters from the user, then the download speed will not even be half that. Here is an example with load speed calculations. Java howto calculates Mbit / s during loop loading.

0
source

Take a look at the Zwitscher NetworkHelper class

Basically you need to get a ConnectivityManager

 cManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 

and then request this for what you want to know

 NetworkInfo info = cManager.getActiveNetworkInfo(); int type = info.getType(); int subType = info.getSubtype(); 

For more information, look at the above class to see the type and subType .

-1
source

All Articles