我想找到路由器的IP地址,我连接,但我的程序给我零(0)IP地址为什么我得到0 IP地址,因为我的WIFI已经工作,我正在运行此代码仿真器。
我的代码是:
WifiManager wifiManager = (WifiManager)this.getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ip = wifiInfo.getIpAddress();
String ipString = String.format("%d.%d.%d.%d",(ip & 0xff),(ip >> 8 & 0xff),(ip >> 16 & 0xff),(ip >> 24 & 0xff));