I have a small home network, and I'd like to figure out IP-address of the host computer within java (Android) app. There are many advices in the Internet, including Stackoverflow.com, but all advised ways give me 127.0.0.1, in fact IP-adresses in my network are like 192.168.1.x. I know that 127.0.0.x are local addresses within this device, whereas 192.168.1.x are IP within local network. Most advised way is InetAddress.getLocalHost().getHostAddress()
, but it also gives 127.0.0.1. Class NetworkInterface
was tried too, with the same result.
Any idea will be appreciated, thanks in advance
PS I've found small program find-local-devices.jar, and it works perfectly, giving what I need (192.168.1.x), but there is no source code.