I could get the MAC address of the Wi-Fi interface in Android by:
final WifiInfo wi = wm.getConnectionInfo();
String mac = wi.getMacAddress();
However, I realized, that when the Wi-Fi acts as wireless access point (router) (a.k.a. Hotspot or tethering or AP), the MAC address is no longer the same. I could know that from adb shell ip addr show
.
When the Wi-Fi connects to a network, adb shell ip addr show
displays:
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
So the MAC addresses differ.
I wonder how do I get a MAC address of the Wi-Fi access point (02:1a:11:xx:xx:xx
) from Java code?