Last active
November 26, 2017 05:11
-
-
Save tolmachevroman/8065b56dc7e17638fc0a16570f5614aa to your computer and use it in GitHub Desktop.
Medium Post 3. Utils.hasConnection()
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
fun hasConnection(): Boolean { | |
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val activeNetwork = cm.activeNetworkInfo | |
return activeNetwork != null && activeNetwork.isAvailable && activeNetwork.isConnected | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment