Possible Duplicate:
How do you get the current DNS servers for Android?
I want to get hold of the dns servers in android. this thread says there is some android.net.NetworkUtils class but I found out that there's no such class. Same question was asked here but it was unresolved.
Here's a Project example that works:
for (long i = start; i < end + 1; i++) {
hosts_done++;
HostBean host = new HostBean();
host.ipAddress = NetInfo.getIpFromLongUnsigned(i);
try {
InetAddress ia = InetAddress.getByName(host.ipAddress);
host.hostname = ia.getCanonicalHostName();
host.isAlive = ia.isReachable(timeout) ? 1 : 0;
} catch (java.net.UnknownHostException e) {
Log.e(TAG, e.getMessage());
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
if (host.hostname != null && !host.hostname.equals(host.ipAddress)) {
// Is gateway ?
if (discover.net.gatewayIp.equals(host.ipAddress)) {
host.deviceType = 1;
}
// Mac Addr
host.hardwareAddress = HardwareAddress.getHardwareAddress(host.ipAddress);
// NIC vendor
try {
host.nicVendor = HardwareAddress.getNicVendor(host.hardwareAddress);
} catch (SQLiteDatabaseCorruptException e) {
Log.e(TAG, e.getMessage());
}
publishProgress(host);
} else {
publishProgress((HostBean) null);