'InetAddress.getAllByName for domain vs chrome on Android

I have a host alias like myservice that is resolved as myservice.mydomain.tld.

I would like to do the ipaddress resolution myself; I tried to call InetAddress.getAllByName("myservice") in my android app but that throws UnknownHostException. Generell resolution works, calling InetAddress.getAllByName("myservice.mydomain.tld") returns expected result.

Now, when i use chrome on the same device and browse https://myservice, chrome is able to resolve as navigation to the page behind https://myservice works.

I tried to search the required calls from chromium/chrome sources but i only found calls to getAllByName as android_getaddrinfofornetwork which is the same as documented.

Any other hints on how apps like chrome do DNS resolution on android?



Solution 1:[1]

Have you tried using Network.getAllByName()? Looks like that'll do the hostname resolution for you, and then return matching InetAddresses

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Caitlyn Wiley