返回列表 發帖

Android App - Ping

private
OnClickListener milistener =
new
OnClickListener()
{
public
void onClick(View v)
{
TextView info =
(TextView)findViewById(R.id.info);
EditText edit =
(EditText)findViewById(R.id.edit);
Editable host = edit.getText();
InetAddress in;
      in=null;
//Definimos la ip de la cual haremos el ping
try
{
   in =
InetAddress.getByName(host.toString());
}
catch
(UnknownHostException e)
{
// TODO Auto-generated catch block
   e.printStackTrace();
}
//Definimos un tiempo en el cual ha de responder
try
{
if(in.isReachable(5000)){
    info.setText("Responde OK");}
else{
      info.setText("No responde: Time out");
}
}
catch
(IOException e)
{
// TODO Auto-generated catch block
   info.setText(e.toString());
}
}
};
Bill Tang     MSN:billtang@openplatform.com.hk
Openplatform Technology Co.,Ltd. 資訊坊科技有限公司  
無線工程施工、方案設計、無線產品、天饋材料、終端設備綜合供應商
Tel: 852-27491011  Fax: 852-81483532

返回列表