Last active
November 3, 2021 00:57
-
-
Save heitorpaceli/c52c7b4afa0ee8f7749042641e91d518 to your computer and use it in GitHub Desktop.
Get SSID of connected WiFi Get SSID of connected WiFi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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