Answers for "kotlin network change listener android"

2

kotlin network change listener android

val connectivityManager = dialog.context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
        connectivityManager?.let {
            it.registerDefaultNetworkCallback(object : ConnectivityManager.NetworkCallback() {
                override fun onAvailable(network: Network) {
                    //take action when network connection is gained
                }
                override fun onLost(network: Network) {
                 

                    //take action when network connection is lost
                }
            })
        }
Posted by: Guest on September-13-2021

Code answers related to "kotlin network change listener android"

Browse Popular Code Answers by Language