问题
public boolean requestRouteToHost (int networkType, int hostAddress)
This method in ConnectivityManager if used with networkType set to wifi interface always returns false.
requestRouteToHost android says it was never implemented for the wifi interface.
Even InetAddress.isReachable() always returns false for publicservers like google.com, java.com
Is there any specific reason why they fail? The only way I could test if there was connectivity was by executing the "ping" by using runtime exec().
回答1:
Apparently this is a bug and this has been raised.
回答2:
This appears to be fixed in ICS. My 2.3 Desire fails in the same way, but my 4.0.4 SGS2 gets a successful true
result from requestRouteToHost over WiFi.
来源:https://stackoverflow.com/questions/8322481/requestroutetohost-returns-false-on-wifi-interface