0
我試圖通過編程方式收集網絡信息(MAC,IP,DNS 1-2,網關,子網掩碼),但我確實在使用DNS 1-2,網關和子網掩碼。你能在這個問題上給我帶頭嗎?如何以編程方式收集網絡信息
使用wifimanager我可以很容易地收集IP和MAC地址。我無法得到其他人。
WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
String ip = Formatter.formatIpAddress(wm.getConnectionInfo()
.getIpAddress());
String mac = wm.getConnectionInfo().getMacAddress();
我還可以從DhcpInfo所有這些信息如下:
DhcpInfo d = wm.getDhcpInfo();
String DNS1 = d.dns1.toString();
但這返回一些整數,我不能把它解析爲DNS。
有沒有其他的方式來獲得DNS和網關。