问题小结(10)-android中ping命令的实现
[java]public static String pingHost(String str){
String resault="";
try {
// TODO: Hardcoded for now, make it UI configurable
Process p = Runtime.getRuntime().exec("ping -c 1 -w 100 " +str);
int status = p.waitFor();
if (status == 0) {
// mTextView.setText("success") ;
resault="success";
}
else
{
resault="faild";
// mTextView.setText("fail");
}
} catch (IOException e) {
// mTextView.setText("Fail: IOException"+"\n");
} catch (InterruptedException e) {
// mTextView.setText("Fail: InterruptedException"+"\n");
}
return resault;
}
作者:agods
补充:移动开发 , Android ,