LANでそのIPアドレスにpingを実行するために、このコードを試しています。結果は申し訳ありません。
ありがとう。あなたが私を助けたら
デバイスからプリンターのIPにpingを送信したい。これはできますか。
String ip_address="\\10.28.81.9";
boolean reachable=false;
TextView txt=(TextView) findViewById(R.id.info);
InetAddress address;
try {
address = InetAddress.getByName(ip_address);
reachable =address.isReachable(3000);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(reachable){
txt.setText("Got it");
}else{
txt.setText("Sorry");
}