Android get WiFi MAC, off WiFi can't get

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.