안녕하세요 안드로이드펍 가족님들..
인터넷검색결과 Ping 으로 해당 ip의 속도를 가져올수 있는 법을 알아냈습니다.
그래서 구글링한 결과. 아래와같은 주소를 찾았는데요.. 거기서도 두번재 사이트에서는
제가 원하는 ms값을 가져오는것이 나왔습니다.
그래서 저두 한번 해보았는데요.
이상하게 로그값으로 아래꺼꺼만 나타납니다.
다른 내용은 나타나지 않는데 왜그런거죠 아래와 같이 구현햇습니다. 이것저것 해보아도 안되는데요 ㅜㅜ
09-24 17:34:22.471: E/kim(2480): Unreachable in 3 sec
http://www.androidpub.com/184015
http://learn-it-stuff.blogspot.kr/2012/01/ping-code-for-android-activity.html
try {
InetAddress ia = InetAddress.getByName("www.naver.com");
if(ia.isReachable(7000)==true) {
Log.e("kim", "Reachable in 3 sec");
// tv.setText("Reachable in 3 sec");
// tv.append("\naaaa");
} else {
Log.e("kim", "Unreachable in 3 sec");
// tv.setText("Unreachable in 3 sec");
}
} catch (UnknownHostException e){
Log.e("kim", "UnknownHostException");
// tv.setText("UnknownHost Exception");
} catch (IOException e) {
Log.e("kim", "IO Exception : " + e.toString());
// tv.setText("IO Exception : " + e.toString());
} catch (IllegalArgumentException e) {
Log.e("kim", "IllegalArgumentExceptio");
// tv.setText("IllegalArgumentExceptio");
}
try {
String pingCmd = "ping -c 5 ";
String pingResult = "";
Runtime r = Runtime.getRuntime();
Process p = r.exec(pingCmd);
BufferedReader in = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
Log.e("kim", inputLine +"\n\n");
//text.setText(inputLine + "\n\n");
pingResult += inputLine;
Log.e("kim", pingResult);
//text.setText(pingResult);
}
in.close();
}//try
catch (IOException e) {
System.out.println(e);
}