Ping应用程序在Android中 [英] Ping Application in Android
本文介绍了Ping应用程序在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我提出将实施的平command.The问题是一些功能的应用程序,我不知道哪个库/库在Android中使用。 任何人有任何想法呢?
I am making an application which will implement some features of the "ping" command.The problem is, I have no idea of which library/libraries to use in ANDROID. anyone have any idea for it?
我曾参观过这些计算器联系,但他们不是非常有帮助。
I have visited these stackoverflow links but they weren't very helpful.
- <一个href="http://stackoverflow.com/questions/13219522/is-there-a-way-to-make-an-android-device-answer-to-icmp-pings-addressed-to-the-b">Is有没有办法让Android设备答案ICMP ping消息给广播地址?
- 问题做平与Android
- <一个href="http://stackoverflow.com/questions/2935325/android-debugging-inetaddress-isreachable/2935468#2935468">Android调试InetAddress.isReachable
- 怎样的ICMP PING在Android
- 如何平外部IP从Java的Android
- Is there a way to make an android device answer to icmp pings addressed to the broadcast address?
- problem to do ping with android
- Android Debugging InetAddress.isReachable
- how to icmp ping on android
- How to Ping External IP from Java Android
推荐答案
我已经使用下列code ping通。
I have used following code to ping.
public String ping(String url) {
String str = "";
try {
Process process = Runtime.getRuntime().exec(
"/system/bin/ping -c 8 " + url);
BufferedReader reader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
int i;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((i = reader.read(buffer)) > 0)
output.append(buffer, 0, i);
reader.close();
// body.append(output.toString()+"\n");
str = output.toString();
// Log.d(TAG, str);
} catch (IOException e) {
// body.append("Error\n");
e.printStackTrace();
}
return str;
}
下面的网址,你需要传递的地址,您要ping通。
Here in the url, you need to pass the address, on which you want to ping.
这篇关于Ping应用程序在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文