Get MAC Address without connect to WiFi

后端 未结 2 1951
既然无缘
既然无缘 2021-02-06 18:41

Is it possible to get WiFi MAC Address without actually connected to it?

Let\'s say I have android device \"A\". I already turn on the WiFi, so that my android device is

相关标签:
2条回答
  • 2021-02-06 19:01
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    registerReceiver(new BroadcastReceiver() {
            @Override
            public void onReceive(Context c, Intent intent) 
            {
               List<ScanResult> results = wifiManager.getScanResults();
               for (ScanResult ap : results) {
                   Log.d(TAG, "SSID=" + ap.SSID + " MAC=" + ap.BSSID); 
               }
            }
    }, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); 
    wifiManager.startScan();
    

    For a BSS operating in infrastructure mode, the BSSID is the MAC address of the wireless access point (WAP)

    0 讨论(0)
  • 2021-02-06 19:13

    Try this bash shell to get the MAC address

    cat /sys/class/net/wlan0/address

    It returns the MAC address under adb shell.

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