Skip to content

Instantly share code, notes, and snippets.

@nadar71
Created October 21, 2020 09:44
Show Gist options
  • Save nadar71/27427636facf6d34553dc8032932cf2e to your computer and use it in GitHub Desktop.
Save nadar71/27427636facf6d34553dc8032932cf2e to your computer and use it in GitHub Desktop.
Basic Check if internet connection is on. Obsolete, using deprecated methods, maust implement this : https://medium.com/swlh/how-to-check-internet-connection-on-android-q-ea7c5a103e3
// Check if internet connection is on
val isConnectionOk: Boolean
get() {
val connManager = (DiceApplication.getsContext() as DiceApplication)
.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val netinfo = connManager.activeNetworkInfo
if (netinfo != null && netinfo.isConnected) {
Log.d(TAG, "Connections is OK !")
return true
} else
Log.d(TAG, "Connections is down !")
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment