I see the 24 similar questions asking about InetAddress.isReachable() but my instance never returns true, when the network is otherwise reachable, with the one exception of tests against 127.0.0.1
.
if (InetAddress.getByName("google.com").isReachable(2000))
{
System.out.println("visible");
}
else
{
System.out.println("not visible");
}
and with permissions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
This code is started within a thread (of course). My App needs to know if a specific IP is accessible (not google, as in the above example). This behaves the same in the emulator.
Is there a better way to test network connectivity?