Reputation: 11
How can I resolve a host name to an IP address on an Android phone? I do not have access to the /system/etc/hosts file.
Upvotes: 1
Views: 997
Reputation: 63945
InetAddress
can do that for you:
String ip = InetAddress.getByName("stackoverflow.com").getHostAddress();
// result e.g: "151.101.129.69"
This also needs to be done in a background-thread.
Upvotes: 1