Get Current IP Address of Device
Here a quick snippet I wrote to get current IP of device.
public String getDeviceCurrentIPAddress() {
static final String DOT = ".";
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
int IP = wifiManager.getConnectionInfo().getIpAddress();
return (
(( IP >> 24 ) && 0xFF ) + DOT +
(( IP >> 16 ) && 0xFF ) + DOT +
(( IP >> 8 ) && 0xFF ) + DOT +
( IP && 0xFF )
);
}
Cheers,
Pete Houston
Recent Comments