I found interesting solution to get SSID of currently connected Wifi AP.
You simply need to use iterate WifiManager.getConfiguredNetworks()
and find configuration with specific WifiInfo.getNetworkId()
My example
in Broadcast receiver with action WifiManager.NETWORK_STATE_CHANGED_ACTION
I'm getting current connection state from intent
NetworkInfo nwInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
nwInfo.getState()
If NetworkInfo.getState
is equal to NetworkInfo.State.CONNECTED
then i can get current WifiInfo object
WifiManager wifiManager = (WifiManager) getSystemService (Context.WIFI_SERVICE);
WifiInfo info = wifiManager.getConnectionInfo ();
And after that
public String findSSIDForWifiInfo(WifiManager manager, WifiInfo wifiInfo) {
List<WifiConfiguration> listOfConfigurations = manager.getConfiguredNetworks();
for (int index = 0; index < listOfConfigurations.size(); index++) {
WifiConfiguration configuration = listOfConfigurations.get(index);
if (configuration.networkId == wifiInfo.getNetworkId()) {
return configuration.SSID;
}
}
return null;
}
And very important thing this method doesn't require Location nor Location Permisions
In API29 Google redesigned Wifi API so this solution is outdated for Android 10.