In Java I have used following code to get ip using hostname
InetAddress address = InetAddress.getByName("hp-PC");
System.out.println(address.getHostAddress());
when I am trying to used this code in android then it display
Host Not Found
error, please help me to solve this problem.
Thanks in advance
For me it works only when I add .local in the host name while getting the IP address of the machine in the local network.
InetAddress address = InetAddress.getByName("hp-PC.local");
System.out.println(address.getHostAddress());
Not sure if this works out for you or not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.