While I'm not necessarily "more experienced with Android or perhaps a
Google engineer"....
It's kind of a weird call to begin with. On a mobile device (and not
only) the network connection can go bad or completely disappear at any time.
Even when this call properly works, it can't predict the future or make
promises that it can keep.
I'd recommend you check ConnectivityManager to see if it's even worth it
to start a network conversation, then handle IOException in case the
connection goes away or was bad to begin with.
-- Kostya
27.12.2010 20:46, bc пишет:
I am stumped. InetAdress.isReachable simply does not work. By that I
mean, it always returns false for an external host.
I have tried searching the internet to see if anybody else is having
the same problem, I have found a few people have had the same problem,
but cannot really find an explanation why.
I have tried this on multiple devices with the same result.
boolean blnResult =
InetAddress.getByName("localhost").isReachable(20000);
The above line of code works every time. If I change the "localhost"
to an external host that I can verify "isReachable", the result is
always false.
blnResult =
InetAddress.getByName("www.google.com").isReachable(20000);
blnResult = InetAddress.getByName("4.2.2.2").isReachable(20000);
The above lines always return false, even though I can use a terminal
emulator on the same device and get a true result.
Can somebody more experienced with Android or perhaps a Google
engineer please give a plausible explanation for this.
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en