Last active
July 14, 2020 14:09
-
-
Save peterpazmandi/66f5013331bff0cc4c654fef241808d3 to your computer and use it in GitHub Desktop.
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
import android.content.Context | |
import android.net.ConnectivityManager | |
import android.net.NetworkInfo | |
object ConnectivityUtil | |
{ | |
fun isConnected(context: Context): Boolean | |
{ | |
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
val activeNetwork: NetworkInfo? = cm.activeNetworkInfo | |
return activeNetwork?.isConnectedOrConnecting == true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment