I\'m trying to find if scanResult is the current connected wifi network.
here is my code
public boolean IsCurrentConnectedWifi(ScanResul
Update Android Oreo. You will also need to add ACCESS_FINE_LOCATION Permission in Manifest otherwise it will return unknown SSID
fun getCurrentSsid(context: Context): String {
var ssid = "NA"
val connManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
if (networkInfo.isConnected) {
val wifiManager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
val connectionInfo = wifiManager.connectionInfo
if (connectionInfo != null && !connectionInfo.ssid.isEmpty()) {
ssid = connectionInfo.ssid
}
}
return ssid
}