Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get MAC address of the WIFI interface in android?

I am using the following code:

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

Problem is, the WIFI must be ENABLED in the device in order for me to read its address. How can I still read the MAC of the WIFI even if the WIFI is off?

like image 435
Himberjack Avatar asked Jun 08 '11 08:06

Himberjack


People also ask

Why does my Android have a Wi-Fi MAC address?

MAC addresses are used by devices when connecting to a Wi-Fi network or an access point. Because these MAC addresses are transmitted without encryption, they can be captured and used to potentially track a user's location. Historically, devices use the factory MAC address to associate to a Wi-Fi network.

Does interface have MAC address?

Yes. For each network interface in your device, there is a unique MAC address associated with it. So if your laptop has both an Ethernet port and Wi-Fi built-in, you will see two MAC addresses in the system configuration.


1 Answers

You can't. Depending on the device, if the wifi adapter is disabled then it may actually be electronically switched off, so you can't read any info from it.

From the Android Developers Blog:

Mac Address

It may be possible to retrieve a Mac address from a device’s WiFi or Bluetooth hardware. We do not recommend using this as a unique identifier. To start with, not all devices have WiFi. Also, if the WiFi is not turned on, the hardware may not report the Mac address.

like image 124
Graham Borland Avatar answered Oct 04 '22 22:10

Graham Borland