Created
March 29, 2017 17:26
-
-
Save mpuz/81ff82e858776ec47b4255817f5f0a87 to your computer and use it in GitHub Desktop.
Android, Java: Get Your OWN IP ADDRESS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); | |
WifiInfo wifiInf = wifiMan.getConnectionInfo(); | |
int ipAddress = wifiInf.getIpAddress(); | |
String ip = String.format("%d.%d.%d.%d", (ipAddress & 0xff),(ipAddress >> 8 & 0xff),(ipAddress >> 16 & 0xff),(ipAddress >> 24 & 0xff)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment