Last active
June 4, 2017 05:15
-
-
Save Trinea/8553088 to your computer and use it in GitHub Desktop.
get the current DNS servers for Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class<?> SystemProperties = Class.forName("android.os.SystemProperties"); | |
Method method = SystemProperties.getMethod("get", new Class[] { String.class }); | |
ArrayList<String> servers = new ArrayList<String>(); | |
for (String name : new String[] { "net.dns1", "net.dns2", "net.dns3", "net.dns4", }) { | |
String value = (String) method.invoke(null, name); | |
if (value != null && !"".equals(value) && !servers.contains(value)) | |
servers.add(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/3070144/how-do-you-get-the-current-dns-servers-for-android#answer-11362271