我想知道设备网络上传速度和延迟,我试过FTP文件上传但没有成功。谁能帮我确定网络上传速度?
最佳答案
获取当前网络连接类型:
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int networkType = telephonyManager.getNetworkType();
以及延迟:
String host = "172.16.0.2";
int timeOut = 3000;
long[] time = new long[5];
Boolean reachable;
for(int i = 0; i < 5; i++)
{
long BeforeTime = System.currentTimeMillis();
reachable = InetAddress.getByName(host).isReachable(timeOut);
long AfterTime = System.currentTimeMillis();
Long TimeDifference = AfterTime - BeforeTime;
time[i] = TimeDifference;
}
关于安卓 : How to get internet connection upload speed and latency?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11013971/