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

后端 未结 4 1275
南旧
南旧 2020-12-02 23:42

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

相关标签:
4条回答
  • 2020-12-02 23:55

    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!

    0 讨论(0)
  • 2020-12-03 00:12

    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.

    0 讨论(0)
  • 2020-12-03 00:13

    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();
    }
    
    0 讨论(0)
  • 2020-12-03 00:20

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

    BSSID explained here.

    0 讨论(0)
提交回复
热议问题