求教如何在android 中调用ping命令 来获取发送和接受消息数目 多谢
解决方案 »
- 求助:关于Intent跳后的activity中View事件监控问题
- 关于拦截短信的问题
- 请问如何实现AttributeSet接口?
- 求助:为甚么run confirguations只有4.0.3版本
- 如何在Android的Activity文件中使用Junit4
- android 错误求解!java.lang.VerifyError:
- root获得
- 关于PreferenceFragment中使用setSharedPreferencesName后ListPreference报错的问题
- app接入高德后怎么定位到自己所在的城市
- PathMeasure 这个类怎么用的?sdk表示看不懂啊,搜也搜不到例子,有没有大神用过的。谢谢~在线等
- android 注册登录如何实现
- android 升级包 版本问题
{
public void run(){ Thread.sleep();
Update();
}
});mHandler= new Handler()
{
@override
public void handleMessage(Message msg){}
}public void Update(){mHandler.sendMessage(mHandler.obtainMessage());
}楼主,你看看这样可以吗?通过不断更新数据,设置个静态变量。去获取。
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec("ping xxxxxxxxx -argv");
mTxtContents = (EditText)findViewById(R.id.TXT_CONTENTS);
mBtnAction.setOnClickListener(this); private void doAction() {
try {
Runtime runtime = Runtime.getRuntime();
System.out.println("hello");
Process proc = runtime.exec("ping fr.yahoo.com -c 1"); // other servers, for example
proc.waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void printText(String text) {
mTxtContents.append(text);
mTxtContents.append("\n");
}
还有就是如何将ping的结果回现到 TxtContents里面?
我才学没多久
private static final boolean pingIpAddr() {
String mPingIpAddrResult;
try {
String ipAddress = "74.125.47.104";
Process p = Runtime.getRuntime().exec("ping -c 1 -w 100 " + ipAddress);
int status = p.waitFor();
if (status == 0) {
return true;
} else {
mPingIpAddrResult = "Fail: IP addr not reachable";
}
} catch (IOException e) {
mPingIpAddrResult = "Fail: IOException";
} catch (InterruptedException e) {
mPingIpAddrResult = "Fail: InterruptedException";
}
return false;
}
而在ADB里,通过命令却可以执行?