How do you get the current DNS servers for Android?

后端 未结 8 790
孤街浪徒
孤街浪徒 2020-11-30 03:01

I\'m trying to get hold of the addresses to the currently used DNS servers in my application, either I\'m connected thru Wifi or mobile. The DhcpInfo object should provide t

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 03:51

    first Add External JARs layoutlib.jar to your build path, the layoutlib.jar file in $SDK_PATH/platforms/android-xxx/data/, then

    String dnsStr1 = android.os.SystemProperties.get("net.dns1");
    String dnsStr2 = android.os.SystemProperties.get("net.dns2");
    

    you also can see all property in adb shell with $getprop command.

提交回复
热议问题