Hey, this can help you: DHCPInfo
final WifiManager manager = (WifiManager) super.getSystemService(WIFI_SERVICE);
final DhcpInfo dhcp = manager.getDhcpInfo();
final String address = Formatter.formatIpAddress(dhcp.gateway);
Add the following lines to AndroidManifest.xml to access the Wi-Fi features:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
Since formatIpAddress is deprecated, you can now use the following code
byte[] myIPAddress = BigInteger.valueOf(manager.getIpAddress()).toByteArray();
ArrayUtils.reverse(myIPAddress);
InetAddress myInetIP = InetAddress.getByAddress(myIPAddress);
String myIP = myInetIP.getHostAddress();
source
share