Reputation: 10623
I want to find out the ip address of the router with i am connect, but my program gives me Zero(0) ip address why i am getting 0 ip address as my WIFI is already working, i am running this code on EMULATOR.
my code is:
WifiManager wifiManager = (WifiManager)this.getSystemService(WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ip = wifiInfo.getIpAddress();
String ipString = String.format("%d.%d.%d.%d",(ip & 0xff),(ip >> 8 & 0xff),(ip >> 16 & 0xff),(ip >> 24 & 0xff));
Upvotes: 0
Views: 133
Reputation: 77
If you want to find out the IP Address of your phone which is connected to any Network or hotspot, you can use the code from this link
android: get IP over WIFI on ICS
Upvotes: 1