I have used this API to pick the mac address of device,
NetworkInterface.getHardwareAddress()
But this is for API level 9 and later, what should i use to pick the mac address for API level 8? froyo device.
May be this a very simple thing, but i tried googling and couldn't find the answer.
WifiInfo.getMacAddress() has been available since API level 1.
WifiManager wifiMan = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInf = wifiMan.getConnectionInfo();
String macAddr = wifiInf.getMacAddress();
You'll need to add:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
To your manifest
WifiInfo.getMacAddress() always gives you Wi-Fi MAC address although your active interface may be currently cellular. If the intended purpose is to get the associated hardware address (such as from cellular connection), then MAC should be retrieved from rmnet0 interface and so on (if IP/MAC association is required).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With