Skip to content Skip to sidebar Skip to footer

Requestroutetohost Android

Greetings everyone! I'm getting rather fed up with android's ConnectivityManager class. I've been trying for 5 hours to get the requestRouteToHost to work. I'm running my code on t

Solution 1:

Looks like requestRouteToHost() is not implemented for WiFi. WifiStateTracker private class does not have requestRouteToHost() implementation. Instead, default implementation from base class NetworkStateTracker always returns false.

Solution 2:

I would recommend testing requestRouteToHost() with a real host. Not only am I unconvinced that localhost as a name is necessarily recognized on Android, it's going to be the device/emulator itself, which would go out via neither WiFi nor 3G, so I would expect requestRouteToHost() to fail.

You might also have a problem with wherever you are getting lookupHost() from. For example, I am not sure if this implementation supports localhost.

Solution 3:

The requestRouteToHost(lookupHost()) combination you are doing is very risky

See your code:

conn_man.requestRouteToHost(ConnectivityManager.TYPE_WIFI, lookupHost("localhost")))

Here, you first made a host lookup, and next you are requesting a route to it. It will work fine only for static addresses (like localhost), where no real lookup is done. If you need a DNS lookup to resolve host address, it will fail easily. Generally, requestRouteToHost is handy for static addresses only.

Post a Comment for "Requestroutetohost Android"