Getting the MAC address of Android Wi-Fi Hotspot / tethering / AP

I can get the MAC address of the Wi-Fi interface in Android:

final WifiInfo wi = wm.getConnectionInfo();
String mac = wi.getMacAddress();
However, I realized that when Wi-Fi acts as a wireless access point (router) (aka access point or access point or access point), the MAC address no longer matches. I could know that from adb shell ip addr show.

When Wi-Fi connects to the network, it adb shell ip addr showdisplays:

10: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether a0:0b:ba:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.25/24 brd 192.168.1.255 scope global wlan0
    inet6 fe80::a20b:baff:fee0:73c7/64 scope link 
       valid_lft forever preferred_lft forever

However, when it acts as an access point,

10: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 02:1a:11:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.1/24 brd 192.168.43.255 scope global wlan0

Thus, the MAC addresses are different.

I wonder how to get the MAC address of a Wi-Fi access point ( 02:1a:11:xx:xx:xx) from Java code?

+4
source share
1 answer
+3

Source: https://habr.com/ru/post/1538519/


All Articles