I'm trying to ping a site to detect wether I have internet or not in my android app. On many devices this does work well, but today, with a new devices, it allways returns that I have no internet.
This is the code:
static public boolean isInternetAvailable(String url){
Runtime runtime = Runtime.getRuntime();
try {
String command = "/system/bin/ping -c 1 " + url;
Process ipProcess = runtime.exec(command);
int exitValue = ipProcess.waitFor();
return (exitValue == 0);
} catch (IOException e) { e.printStackTrace(); }
catch (InterruptedException e) { e.printStackTrace(); }
return false;
}
Even though the server is online, and I can ping it from various other devices, on the new device it allways returns false. Could it be possible that the ping command is blocked for some reason? The new device is a Samsung GT-19305 with Android version 4.3.