首页 文章

无需连接WiFi即可获取MAC地址

提问于
浏览
2

是否可以在没有实际连接的情况下获取WiFi MAC地址?

假设我有Android设备“A” . 我已打开WiFi,以便我的Android设备现在能够检测到附近的WiFi SSID广播 .

附近我有一些WiFi SSID广播如下:

SSID =炒作,MAC_ADDRESS = 00:39:E0:33:00 SSID =哑,MAC_ADDRESS = 02:33:DF:39:89 SSID = bilbo,MAC_ADDRESS = D0:32:E8:97:29

如果没有实际连接到WiFi SSID bilbo ,我可以拥有其MAC_ADDRESS吗?

请帮忙,谢谢 .

2 回答

  • 1
    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)

  • 4

    试试这个bash shell来获取MAC地址

    cat /sys/class/net/wlan0/address

    它返回 adb shell 下的MAC地址 .

相关问题