Android obtains mac addresses. android obtains mac addresses.
Http://www.cnblogs.com/xioapingguo/p/4037513.html
Find it online, record it
public static String getMacAdress(){ WifiManager wifi = (WifiManager) sContext.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); return info.getMacAddress(); }
Remember to add the permission <uses-permission android: name = "android. permission. ACCESS_WIFI_STATE"> </uses-permission>
How does android obtain the Ethernet mac address?
This article describes how to obtain the wireless network and Ethernet mac address: 1. obtain the mac address over ethernet because the set-top box system is Linux kernel. If the ethernet is eth0, you can read the related information from the following file:/sys/class/net/eth0/address Method 1: public static String loadFileAsString (String filePath) throws java. io. IOException {StringBuffer fileData = new StringBuffer (1000); BufferedReader reader = new BufferedReader (new FileReader (filePath); char [] buf = new char [1024]; int numRead = 0; while (numRead = reader. read (buf ))! =-1) {String readData = String. valueOf (buf, 0, numRead); fileData. append (readData);} reader. close (); return fileData. toString ();}/** Get the STB MacAddress */public String getMacAddress () {try {return loadFileAsString ("/sys/class/net/eth0/address "). toUpperCase (). substring (0, 17);} catch (IOException e) {e. printStackTrace (); return null ;}} Method 2: NetworkInterface NIC = NetworkInterface. getByName (" Eth0 "); byte [] buf = NIC. getHardwareAddress (); for (int I = 0; I <buf. length; I ++) {mac = mac + byteHEX (buf);} if (mac! = Null &&! "". Equals (mac) {} 2. to obtain mac and ip addresses from wifi, you must first go to manifest. add permissions to the xml file: <uses-permission android: name = "android. permission. ACCESS_WIFI_STATE "> </uses-permission> The following WifiManager wifi = (WifiManager) getSystemService (Context. WIFI_SERVICE); WifiInfo = wifi. getConnectionInfo (); return info. getMacAddress (); public String getLocalIpAddress () {try {for (Enumeration <NetworkInterface> en = NetworkInterface. getNetworkInterfaces (); en. hasMoreElements ();) {Net ...... remaining full text>
How can I view the Mac address of an Android phone?
It's easy to go To the WLAN settings in the settings, and then press the menu key of the mobile phone. A small interface is displayed at the bottom of the screen. Go to the Advanced page, where you can see the MAC address or settings and enter the phone information about the mobile phone.
And then select the hardware information. The MAC address is also displayed. This method is also applicable to mobile phones on other Android platforms.