Android Question Ping IP

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

Just wondering how I can ping a IP address and get a reply back saying Pass or Fail if it was able to be pinged.

I have used the following code but I can't work out how to make it say Pass or Fail

B4X:
Dim p As Phone
Dim sb As StringBuilder
	sb.Initialize
	p.Shell("ping -c 1 192.168.0.1",Null,sb,Null)
Log(sb)

Anyone able to help so it only says Pass or Fail if the IP was able to be pinged ?
 

aaronk

Well-Known Member
Licensed User
Longtime User
However I don't recommend you to use this code as it will block the main thread.

What do you mean block the main thread ?

As my app will connect to a TCP socket using a port number, I want to add something to the app (such as ping test) so if the user can't connect to the IP/port they can run some type of test and see if the device can talk to that IP or not.
 
Upvote 0
Top