Comprueba la tasa de ancho de banda en Android

Tenemos una opción para comprobar los tipos de conexión de red en android (ya sea 3G, borde o gprs).

Tengo que comprobar la tasa de ancho de banda. Necesito initaite una llamada .. Para eso tengo que comprobar la tasa de ancho de banda .. Por encima de un badnwidth particular sólo tengo que hacer visible una opción para una llamada (para iniciar una llamada). Así que cómo comprobar la tasa de ancho de banda.

Necesito encontrar la velocidad de la conexión programmatically (velocidad de la conexión para el enlace de datos móvil, EDGE) … Please help

Puede descargar un archivo de tamaño conocido de su servidor y calcular cuánto tiempo tardó en descargarlo. Entonces usted tiene su ancho de banda. Simple pero funciona 🙂

Muestra, no probado:

//Download your image long startTime = System.currentTimeMillis(); HttpGet httpRequest = new HttpGet(new URL(urlString).toURI()); HttpClient httpClient = new DefaultHttpClient(); HttpResponse response = (HttpResponse) httpClient.execute(httpRequest); long endTime = System.currentTimeMillis(); HttpEntity entity = response.getEntity(); BufferedHttpEntity bufHttpEntity; bufHttpEntity = new BufferedHttpEntity(entity); //You can re-check the size of your file final long contentLength = bufHttpEntity.getContentLength(); // Log Log.d(TAG, "[BENCHMARK] Dowload time :"+(endTime-startTime)+" ms"); // Bandwidth : size(KB)/time(s) float bandwidth = contentLength / ((endTime-startTime) *1000); 

Esto devuelve la velocidad del enlace actual en LINK_SPEED_UNITS.

Pero este trabajo sólo para WIFI Only

 WifiManager wifiManager = Context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo != null) { Integer linkSpeed = wifiInfo.getLinkSpeed(); //measured using WifiInfo.LINK_SPEED_UNITS } 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.