We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Please, could someone give me an example of android code to make a ping to a IP address and get the result?
@ArSkigner===
what kind of IP??? LAN??? - what kind of connection (wifi, bluetooth...)???
I just want to develop a app to ping all the devices of my house connected on wifi
This is not from android (at least I didn't tested on it), but it worked to ping my android device from my laptop (Notice device must be unlocked as in awake):
public boolean isOnline() { Runtime runtime = Runtime.getRuntime(); try { Process ipProcess = runtime.exec("ping xxx.xxx.xxx.xxx"); int exitValue = ipProcess.waitFor(); return (exitValue == 0); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); }return false; }
This is from reference: https://stackoverflow.com/questions/3584210/preferred-java-way-to-ping-an-http-url-for-availability
One link that could help: https://stackoverflow.com/questions/12428675/list-devices-on-local-network-with-ping
From what I read, not all devices could be configured to respond to pings. I found this app might do what you want. I suggest you use it and see if it can see all the devices that you are looking for. If it does, great, then continue searching for the code: https://www.techrepublic.com/article/locate-devices-on-your-wireless-network-in-seconds-with-fing/
Kf
Thanks kfrajer, I will try
Answers
@ArSkigner===
what kind of IP??? LAN??? - what kind of connection (wifi, bluetooth...)???
I just want to develop a app to ping all the devices of my house connected on wifi
This is not from android (at least I didn't tested on it), but it worked to ping my android device from my laptop (Notice device must be unlocked as in awake):
This is from reference: https://stackoverflow.com/questions/3584210/preferred-java-way-to-ping-an-http-url-for-availability
One link that could help:
https://stackoverflow.com/questions/12428675/list-devices-on-local-network-with-ping
From what I read, not all devices could be configured to respond to pings. I found this app might do what you want. I suggest you use it and see if it can see all the devices that you are looking for. If it does, great, then continue searching for the code:
https://www.techrepublic.com/article/locate-devices-on-your-wireless-network-in-seconds-with-fing/
Kf
Thanks kfrajer, I will try