How can you find the IP address of the router (gateway address) from code?
WifiInfo.getIpAddress()
- returns IP address of device.
In a shell command "ipconfig" does not return any value.
Here is my solution, but please let me know if there is a better way to do this:
WifiManager manager = (WifiManager)getSystemService(WIFI_SERVICE);
DhcpInfo info = manager.getDhcpInfo();
info.gateway;
ipconfig
is a windows command. The linux command isifconfig
with an F. Android doesn't seem to this either and usesnetcfg
– Cathaifconfig
.netcfg
return ip of device:( – Pint