Can I find the MAC address of my Access point in Android?

ぐ巨炮叔叔 提交于 2019-11-27 13:11:11

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: http://www.flattermann.net/2011/02/android-howto-find-the-hardware-mac-address-of-a-remote-host/ to do your bidding. Good luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!