Created
May 5, 2020 18:17
-
-
Save hissain/a1763275d7045b556d648ea39b1fa8cd to your computer and use it in GitHub Desktop.
hasNetworkAvailable API
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
| private fun hasNetworkAvailable(context: Context): Boolean { | |
| val service = Context.CONNECTIVITY_SERVICE | |
| val manager = context.getSystemService(service) as ConnectivityManager? | |
| val network = manager?.activeNetworkInfo | |
| Logger.d(classTag, "hasNetworkAvailable: ${(network != null)}") | |
| return (network != null) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment