I\'m looking for a solution to resolve .local host names with Android 4.0.4 (no NSD, due to API level 15). On the device I don\'t have any service to discover, just the host
You should be able to use the InetAddress
class to resolve the hostname for a given IP address. For example, using the IP address provided in the original question, try the following:
try
{
String hostname = InetAddress.getByName("10.202.0.29").getHostName();
}
catch (UnknownHostException e)
{
Log.e("MyApplication", "Attempt to resolve host name failed");
}
Since this is a network operation, make sure that it is not performed on the UI thread.
EDIT
You should be able to resolve a local hostname with jmDNS as follows:
InetAddress localHost = InetAddress.getByName("10.202.0.29");
JmDNS jmdns = JmDNS.create(localHost);
String localHostName = jmdns.getHostName();