How can I ping some web server in Android to test if I've Internet connection? So I need the method which pings the given site and returns false if I've no Internet and true if I have.
Using Ping App Grab your smartphone, and launch the Ping app. If you haven't installed the app yet please go to Play Store and download it first. Then tap the start button. Wait for a second and you will see the results of the data connection on your Android smartphone screen.
You can Ping your application server from anywhere as long as you know its IP address. From within your network, find the network IP address of the application server. Just give that IP address with the Ping command, for example, ping 192.168. 0.20.
Much like iOS, the Android operating system does not come with a way to ping other routers or servers by default. Luckily, there are many apps available on Google Play Store that will allow you to do this. Some of the apps you can use include “Ping,” “Ping & Net,” and “PingTools Network Utilities.”
See this method, it's the best way to check for connectivity to a given server:
http://developer.android.com/reference/java/net/InetAddress.html#isReachable(int)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With