关于ping 和消息回现

zhengzhi60 2011-04-04 12:40:59

mBtnAction = (Button)findViewById(R.id.BTN_ACTION);
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里面?
点击按钮后无响应?
求助
...全文
43 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
儿大不由爷 2011-04-04
  • 打赏
  • 举报
回复
可以把ping的结果输入到文件中,然后再读取。

80,359

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧