Skip to content

Instantly share code, notes, and snippets.

@mitchtabian
Created December 22, 2020 19:37
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 mitchtabian/2f5763101658ddef46a56b143dcac8a1 to your computer and use it in GitHub Desktop.
Save mitchtabian/2f5763101658ddef46a56b143dcac8a1 to your computer and use it in GitHub Desktop.
fun isConnectedToTheInternet(): Boolean{
val cm = application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
try{
return cm.activeNetworkInfo.isConnected
}catch (e: Exception){
Log.e(TAG, "isConnectedToTheInternet: ${e.message}")
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment