Skip to content

Instantly share code, notes, and snippets.

@heitorpaceli
Last active November 3, 2021 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heitorpaceli/c52c7b4afa0ee8f7749042641e91d518 to your computer and use it in GitHub Desktop.
Save heitorpaceli/c52c7b4afa0ee8f7749042641e91d518 to your computer and use it in GitHub Desktop.
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