Created
October 4, 2021 18:56
-
-
Save ber4444/a285b3ab496cffbd3f11f96b8479bd72 to your computer and use it in GitHub Desktop.
check network connectivity on android
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
fun Context.internetAvailable(): Boolean { | |
val connectivityManager = this.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager | |
return connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)?.hasCapability(NET_CAPABILITY_INTERNET) == true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment