I am making an Android application that gets a list of all devices connected to my LAN (like their IP addresses and MAC addresses), something similar to what the Fing application does.
Now what I want to do is get the host names on my local network. For instance -
The IP address "192.168.1.221" returns the host name of "Sherlock".
Here, Sherlock is the device name (or host name) of my computer.
I have already tried
- InetAddress.getByName ("192.168.1.221") getHostName () ;.
- InetAddress.getByName ("192.168.1.221") getCanonicalHostName () ;.
But they continue to return the IP address itself.
Can someone help me with the right path? Perhaps there is some kind of Linux command that I could run in Runtime. All that helps.
Thanks in advance:)
source
share