Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hissain/a1763275d7045b556d648ea39b1fa8cd to your computer and use it in GitHub Desktop.

Select an option

Save hissain/a1763275d7045b556d648ea39b1fa8cd to your computer and use it in GitHub Desktop.
hasNetworkAvailable API
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