我正在尝试收集网络信息(MAC,IP,DNS 1-2,GateWay,子网掩码),但我真的与DNS 1-2,GateWay和子网掩码斗争。你能在这个问题上给我一个线索吗?
使用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和网关。
发布于 2014-10-10 11:16:40
我刚刚编辑代码从以下问题的选定答案,以获得所需的网络信息。这似乎不明智,但却适用于我的案子。
How to configue a static IP address, netmask, gateway programmatically on Android 3.x or 4.x
https://stackoverflow.com/questions/26296734
复制相似问题