Reputation: 11
I am developing a android app and i want to get the Wi-Fi mac address of the device when connected to the mobile hotspot and save it to my database.
How can I do this?
Upvotes: 0
Views: 90
Reputation: 352
After Android 6.0 Changes
To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.
Before Android 6.0 Changes the MAC address can be received via the WifiManager.
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = manager.getConnectionInfo();
String address = info.getMacAddress();
Upvotes: 1