My final destination is to get all BSSIDs of the current connected WIFI network in Android.
If I’m right, Android does not support this feature, like Windows do with WlanGetNetworkBssList
.
Because of this, I have to get a list of all available WIFI networks, and use the BDDIDs of them, with the same SSID (user readable WIFI name).
I tries this with:
_connectivityManager = App.Context.GetSystemService(Context.ConnectivityService) as ConnectivityManager;
var requestBuilder = new NetworkRequest.Builder();
requestBuilder.SetIncludeOtherUidNetworks(true);
requestBuilder.AddTransportType(Android.Net.TransportType.Wifi);
_connectivityManager.RegisterNetworkCallback(requestBuilder.Build(), new MyNetworkCallback());
and with:
private class MyNetworkCallback() : ConnectivityManager.NetworkCallback((int)NetworkCallbackFlags.IncludeLocationInfo)
{
...
public void OnCapabilitiesChanged(Android.Net.Network network, NetworkCapabilities networkCapabilities)
{
if (networkCapabilities.TransportInfo is WifiInfo wifiInfo
&& wifiInfo.SupplicantState == SupplicantState.Completed
&& wifiInfo.SSID == _mySSID)
_myBssids.Add(wifiInfo.BSSID);
}
...
}
I granted the permissions ACCESS_FINE_LOCATION
, ACCESS_NETWORK_STATE
, ACCESS_WIFI_STATE
, CHANGE_NETWORK_STATE
and CHANGE_WIFI_STATE
.
Unfortunately, this code only tells me the BSSID of the current connected network, but I would like to get it of all available networks.