Reputation: 35
Im trying to get the mac address of the Access point to which my devices are connected in Android 10 by
WifiManager wifiManager = (WifiManager) applicationContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
wifiManager.getConnectionInfo().getBSSID(); //always gets 02:00:00:00:00:00
as it is written https://developer.android.com/reference/android/net/wifi/WifiInfo#getBSSID(), this result should only come, when im missing rights
i have the following permissions
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
What else do i need?
This question has been asked before, but i only found answers that were years old and not working in Android 10. Thanks for your help
Upvotes: 0
Views: 1947
Reputation: 166
As it is written https://developer.android.com/reference/android/net/wifi/WifiInfo#getBSSID()
getBSSID
returns "02:00:00:00:00:00"
, if the caller has insufficient permissions to access the BSSID.
You have added following permissions in manifest.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
But you need to take runtime permission for these above mentioned permission.
Please check Android Documentation from following URL to know how to implement runtime permission request.
https://developer.android.com/training/permissions/requesting
Upvotes: 1