问题
Is there a way to get all current system DNS resolver ip-addresses in codename one?
The classes NetworkManager
and ConnectionRequest
don't provide these information.
In general Codename One seems not to provide any way to access a devices communication status information like "Wi-Fi Mac address", "IMEI", "Mobile network type" etc. Am I right?
回答1:
Do you mean something like Socket.getHostOrIP()
?
There is no standardized explicit DNS lookup API though.
Most of these things aren't available across platform or even consistently within the platform. You can use Display's getProperty
with "IMEI"
, "UDID"
& "MSISDN"
. But that will only have any chance of working on Android and you will probably need to add the build hint for permissions.
You can also always use native code calls as explained in the developer guide and the How Do I? video.
I would suggest that you revisit your need to get these values and evaluate a way around them. E.g most advertisers no longer require them as they aren't provided by all mobile OS's.
来源:https://stackoverflow.com/questions/37040610/how-to-get-current-system-dns-resolvers-ip-addresses-in-codename-one