I have this code working on Android 4.0.3 on the Nexus One:
WifiManager wifi = (WifiManager) getSystemService(WIFI_SERVICE);
DhcpInfo info = wifi.getDhcpInfo();
String s_gateway = String.valueOf(info.gateway);
String gatewayString = intToIp(Integer.parseInt(s_gateway));
Log.d("DHCP Info: ", s_gateway+"");
Log.d("DHCP Info: ", gatewayString+"");
It’s return me gateway (PC + Connectify) correctly.
But the same code on Android 2.2 return 0.0.0.0. What is wrong?
The way I fixed it: