How to get the WIFI interface MAC address in android?

I am using the following code:

WifiManager wifiMgr = (WifiManager) app.getSystemService(Context.WIFI_SERVICE); return wifiMgr.getConnectionInfo().getMacAddress(); 

The problem is that WIFI must be enabled on the device so that I can read its address. How can I read the WIFI MAC address even if WIFI is disabled?

+6
source share
2 answers

You can not. Depending on the device, if the Wi-Fi adapter is disabled, it can be actually disabled by the electronics, so you cannot read information from it.

From the Android Developers Blog :

Mac Address

It may be possible to get the Mac address from WiFi or Bluetooth devices. We do not recommend using this as a unique identifier. For starters, not all devices have WiFi. In addition, if Wi-Fi is not turned on, the equipment may not report the Mac address.

+15
source
 WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE); String mac = wm.getConnectionInfo().getMacAddress(); 
-9
source

Source: https://habr.com/ru/post/890039/


All Articles