Skip to content

Instantly share code, notes, and snippets.

@GregKluska
Created July 26, 2020 17:09
Show Gist options
  • Select an option

  • Save GregKluska/afd355dd9148a9b844b17fd74b32bc6f to your computer and use it in GitHub Desktop.

Select an option

Save GregKluska/afd355dd9148a9b844b17fd74b32bc6f 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