Android Question WiFi Mac address?

techknight

Well-Known Member
Licensed User
How do I obtain the mac address to the WiFi radio?

I know there is a library ABWifi, but according to the author, just about all functions were dropped in 2.0 and he claims there are "better" libraries out there.

But I am not seeing any? any ideas?
 

walterf25

Expert
Licensed User
How do I obtain the mac address to the WiFi radio?

I know there is a library ABWifi, but according to the author, just about all functions were dropped in 2.0 and he claims there are "better" libraries out there.

But I am not seeing any? any ideas?
You can do it like this:
B4X:
Log("Mac Address: " & Get_Mac)

Sub Get_Mac As String
Dim R As Reflector
R.Target = R.GetContext
R.Target = R.RunMethod2("getSystemService", "wifi", "java.lang.String")
R.Target = R.RunMethod("getConnectionInfo")
Log(R.RunMethod("getMacAddress"))
Return R.RunMethod("getMacAddress")
End Sub

Hope this helps.
Walter
 
Upvote 0

techknight

Well-Known Member
Licensed User
Thats better. Hopefully this doenst throw up the precision location permission flag. ABWifi does and that can scare some people off...
 
Upvote 0

FrankBerra

Active Member
Licensed User
Actually I am using ABWifi to perform scans periodically (every 10 minutes) but seems it is draining too much battery.
So i want to try different approaches: How to obtain the list of MAC/BSSID of the accespoints nearby with getScanResults () ?

Thanks in advance
 
Upvote 0
Top