(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 |