I am trying to get the name of computer from its local IP. This is what I've done so far, but nothing works it just returns the IP address as hostname
InetAddress addr = null;
String hostIP = "192.168.100.10";
try {
addr = InetAddress.getByName(hostIP);
} catch (UnknownHostException e) {
System.out.println("Host " + hostIP + " not found!");
}
String host = addr.getHostAddress();
String hostname= addr.getHostName();
String hostname2 = addr.getCanonicalHostName();
I am expecting to get DESKTOP-DWASDFW as hostname but instead i get 192.168.100.10
UPDATE:
I managed to "fix" it by adding my computer and its ip address manually into the router configuration
but this isn't what im looking for as it requires manually entering every name and IP address. I want something like this app WakeOnLan, it can scan the whole network and get IP address, MAC address and hostname. This app uses arp requests, i researched a lot about how to accomplish something like that in android but found nothing that worked for me (I'm using android 4.2.2)