Skip to content

Instantly share code, notes, and snippets.

@alashstein
Created June 21, 2021 13:38
Show Gist options
  • Save alashstein/5a64856f4d71c73cbc2794e0b828387f to your computer and use it in GitHub Desktop.
Save alashstein/5a64856f4d71c73cbc2794e0b828387f to your computer and use it in GitHub Desktop.
WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
String ipString = String.format("%d.%d.%d.%d", (ip & 0xff), (ip >> 8 & 0xff), (ip >> 16 & 0xff), (ip >> 24 & 0xff));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment