Recently, I've been trying to get native MAC addresses from the NDK with C + + on Android, but with the IOCTL (SIOCGIFHWADDR), the return value is less than 0, which means that the interface information is not available. At first I thought it was my own missing access rights, so I have been increasing uses-permission, and later found that no matter how this is the case, found that the original Android studio virtual machine did not turn on wifi caused.
Because the WiFi MAC address is a passive information. Generally after the boot, will not be actively reported to the system. The MAC address data will not be recorded in the system until the WiFi hardware is started. So to get the MAC address, one is to wait for the WiFi boot, one in the program to initiate WiFi, get the MAC address and then turn off WiFi.
(Note: After traversing the Android emulator interface, found that the network card name only Eth0 and lo (loopback interface) Two, so the general choice to specify back to Eth0)
Android get WiFi MAC, off WiFi can't get