Last active
May 10, 2022 09:27
-
-
Save shikto1/35fc8cf5e8c3e5ecd3f3a8af24921f68 to your computer and use it in GitHub Desktop.
This file contains 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 isInternetAvailable(context: Context): Boolean { | |
var isConnected: Boolean = false // Initial Value | |
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val activeNetwork: NetworkInfo? = connectivityManager.activeNetworkInfo | |
if (activeNetwork != null && activeNetwork.isConnected) | |
isConnected = true | |
return isConnected | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment