Skip to content

Instantly share code, notes, and snippets.

@heitorpaceli
Last active Nov 3, 2021
Embed
What would you like to do?
Get SSID of connected WiFi Get SSID of connected WiFi
private fun getCurrentWifiSsid(): String? {
val context = InstrumentationRegistry.getInstrumentation().context
val wifiManager = context.getSystemService(Context.WIFI_SERVICE) as WifiManager
val wifiInfo = wifiManager.connectionInfo
// The SSID is quoted, then we need to remove quotes
return wifiInfo.ssid?.removeSurrounding("\"")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment