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
class NetworkManager() { | |
val context = YourApplication.appContext | |
private lateinit var networkCallback: ConnectivityManager.NetworkCallback | |
private val connectivityManager = context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager | |
private val _isNetworkAvailable = MutableStateFlow(false) | |
val isNetworkAvailable: StateFlow<Boolean> = _isNetworkAvailable.asStateFlow() | |
init { | |
networkCallback = createNetworkCallback() |