I am trying to write a part in my app that will differentiate between an Active Wifi connection and an actual connection to the internet. Finding out if there is an active Wifi connection is pretty simple using the connection manager however every time I try to test if I can connect to a website when the Wifi is connected but there is no internet connection I end up in an infinite loop.  

I have tried to ping google however this ends up the same way:

```
Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.com");
int returnVal = 5;
try {
    returnVal = p1.waitFor();
} catch (InterruptedException e) {
    e.printStackTrace();
}
boolean reachable = (returnVal==0);
return reachable;

```

I also tried this code:

```
if (InetAddress.getByName("www.xy.com").isReachable(timeout))
{    }
else
{    }

```

but I could not get isReachable to work.