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
Solution 1:
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.
Solution 2:
WifiManagerwm= (WifiManager) getSystemService(Context.WIFI_SERVICE);
Stringmac= wm.getConnectionInfo().getMacAddress();
Post a Comment for "How To Get Mac Address Of The Wifi Interface In Android?"