wifi – Can I find the MAC address of my Access point in Android?-ThrowExceptions

Exception or error:

Can my Android app find the MAC address of the Wifi access point it is connected to?

The docs for android.net.wifi.WifiInfo getMacAddress() don’t provide any details. See http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getMacAddress().
I’m assuming this is the Mac address of my phone. Can I find the Mac address of the access point?

How to solve:

getBSSID() of WifiInfo class will return MAC address of remote access point.

BSSID explained here.

###

The following method will return the MAC address of the access point, null if there is no network currently connected.

public String getMacId() {

    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    return wifiInfo.getBSSID();
}

###

Check out the application “Network Info II” from the Android Market. It does show the MAC address, but I’m not sure if this is still the phone’s MAC. It also shows the BSSID, which has the same format as a MAC address so perhaps is what you’re looking for.

###

I’m fairly sure that getMacAddress(), is, as you suspected for the Local Device.

If you can get the IP of the router/gateway/accesspoint, then you might be able to use the code in this post: https://web.archive.org/web/20160308014312/http://www.flattermann.net/2011/02/android-howto-find-the-hardware-mac-address-of-a-remote-host/ to do your bidding. Good luck!

Leave a Reply

Your email address will not be published. Required fields are marked *