Get MAC Address without connect to WiFi

最后都变了- 提交于 2019-12-04 09:48:14

问题


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 now able to detect nearby WiFi SSID broadcasted.

Nearby I have a few WiFi SSIDs broadcasted as listed below:

SSID=hype, MAC_ADDRESS=00:39:E0:33:00 SSID=dummy, MAC_ADDRESS=02:33:DF:39:89 SSID=bilbo, MAC_ADDRESS=D0:32:E8:97:29

Without actually connected to WiFi SSID bilbo, can I have its MAC_ADDRESS?

Please help, thanks.


回答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)




回答2:


Try this bash shell to get the MAC address

cat /sys/class/net/wlan0/address

It returns the MAC address under adb shell.



来源:https://stackoverflow.com/questions/18549373/get-mac-address-without-connect-to-wifi

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