1. How to obtain the MAC address of a local machine from Android:
You need to add permissions to the androidmanifest. xml file:
<Uses-Permission Android: Name = "android. Permission. access_wifi_state"/>
Public String getlocalmacaddress () {wifimanager WiFi = (wifimanager) getsystemservice (context. wifi_service); wifiinfo info = wifi. getconnectioninfo (); Return info. getmacaddress ();}
2. How to obtain the local IP address for Android:
Public String getlocalipaddress () {try {for (enumeration <networkinterface> en = networkinterface. getnetworkinterfaces (); en. hasmoreelements ();) {networkinterface INTF = en. nextelement (); For (enumeration <inetaddress> enumipaddr = INTF. getinetaddresses (); enumipaddr. hasmoreelements ();) {inetaddress = enumipaddr. nextelement (); If (! Inetaddress. isloopbackaddress () {return inetaddress. gethostaddress (). tostring () ;}}} catch (socketexception ex) {log. E ("wifipreference IPaddress", Ex. tostring ();} return NULL ;}