Я хотел бы узнать время установления связи, время соединения, время запроса, когда наш телефон получил доступ к URL-адресу HTTP. Похоже, что у Android нет API для получения.Не могли бы вы сказать мне решение?Ваша помощь очень ценится.
URL url;
HttpsURLConnection connection = null;
String charset = "UTF-8";
try {
//Create connection
url = new URL("Http://XXX");
connection = (HttpsURLConnection)url.openConnection();
connection.setReadTimeout( 10000 /*milliseconds*/ );
connection.setConnectTimeout( 10000 /* milliseconds */ );
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.connect();
//I want the get the time as following.
//Handshake time
//Connection time
//Request data time
} catch (Exception e) {
e.printStackTrace();
} finally {
if(connection != null) {
connection.disconnect();
}
}