Android gets Mac

Source: Internet
Author: User

(1) Call the android API networkinterface. gethardwareaddress ()

The API level is 9. This API is available only for Android 2.3 and later versions.

(2) method for calling Java: NBTSTAT/ARP

Android generally does not support these two commands.

(3) Call the android API: wifimanager

Permission:

?
1 <uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"></uses-permission>

Code:

?
12345 WifiManager
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
 WifiInfo
info = wifi.getConnectionInfo();
 return info.getMacAddress();

This is when the device enables a Wi-Fi connection and obtains the MAC address of the NIC.

(4) Call Linux busybox

?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 /*
  *****************************************************************  *
Sub-function: Obtain the local MAC address
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.