Created
October 21, 2020 09:44
-
-
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
This file contains hidden or 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
// 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