jen*_*fer 12 android bandwidth codec
我们可以选择检查Android中的网络连接类型(无论是3G,边缘还是gprs).
我需要检查带宽率.我需要发起一个电话.为此,我需要检查带宽率.仅在特定带宽之上,我需要为呼叫提供可见选项(以发起呼叫).
我需要以编程方式找到连接速度(Mobile Data Link,EDGE的连接速度).
Cam*_*e R 17
您可以从服务器下载已知大小的文件,并计算下载它所需的时间.然后你有你的带宽.简单但有效:)
样品,未测试:
//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);
Run Code Online (Sandbox Code Playgroud)
这将返回当前链接速度 LINK_SPEED_UNITS.
但这项工作 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
}
Run Code Online (Sandbox Code Playgroud)