Get native IP address
Public String getlocalipaddress () {
Wifimanager Wifimanager = (wifimanager) getsystemservice ( Android.content.Context.WIFI_SERVICE);
Wifiinfo wifiinfo = Wifimanager.getconnectioninfo ();
int ipaddress = wifiinfo.getipaddress ();
try {return
inetaddress.getbyname (String.Format ("%d.%d.%d.%d"
), (IPAddress & 0xFF), (IPAddress >> 8 & 0xFF),
(IPAddress >> & 0xFF), (IPAddress >> & 0xFF)). toString ();
catch (Unknownhostexception e) {
//TODO auto-generated catch block
e.printstacktrace ();
}
return null;
}
Get Physical address for this machine
Public String getlocalmacaddress () {
Wifimanager WiFi = (wifimanager) getsystemservice (context.wifi_service);
Wifiinfo info = wifi.getconnectioninfo ();
return info.getmacaddress ();
}
The above is Android access to mobile phone IP and MAC address method, I hope to help readers, thank you for your support for this site!