Skip to content

Instantly share code, notes, and snippets.

@vladimirpetrovski
Created July 24, 2020 19:23
Show Gist options
  • Select an option

  • Save vladimirpetrovski/db32ca9dfe370b035a231ea8f51d299e to your computer and use it in GitHub Desktop.

Select an option

Save vladimirpetrovski/db32ca9dfe370b035a231ea8f51d299e to your computer and use it in GitHub Desktop.
val network: Network? = connectivityManager.allNetworks.find {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
connectivityManager.getNetworkCapabilities(it)
.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
} else {
connectivityManager.getNetworkInfo(it).extraInfo == wifiSSID
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment