NetState is a blazing-fast, tiny, lifecycle-aware Android library that helps developers detect:
- 🌐 Real-time Internet On/Off
- 📶 Network Type (WiFi / Mobile / None)
- ⚡ Instant Connectivity State
- 🌀 Reactive Flows for network events
- 🔥 Zero-boilerplate, tiny footprint, production ready
Designed with modern Android development practices using Kotlin, Coroutines, Flow, and Clean Architecture.
Add this to your module-level build.gradle:
dependencies {
implementation("com.avikmakwana:netstate:1.0.1")
}That's it. No setup. No permissions needed. Plug & play. 🚀
private val netState by lazy { NetStateMonitor(applicationContext) }lifecycleScope.launch {
netState.networkState.collect { state ->
when (state) {
is NetworkState.Connected -> {
Log.d("NetState", "Connected: ${state.type}")
}
NetworkState.Disconnected -> {
Log.d("NetState", "Disconnected")
}
}
}
}val isOnline = netState.isConnected()
val type = netState.currentNetworkType()NetworkType.WIFI
NetworkType.MOBILE
NetworkType.NONE@Composable
fun NetworkStatusText(netState: NetStateMonitor) {
val state by netState.networkState.collectAsState(initial = NetworkState.Disconnected)
Text(
text = when (state) {
is NetworkState.Connected -> "Online (${(state as NetworkState.Connected).type})"
NetworkState.Disconnected -> "Offline"
}
)
}Avinash Makwana
Android Developer (3+ YOE) | Health-Tech | AI-Driven App Enthusiast
🌟 Passionate about modern Android development using Kotlin, Coroutines, Flow, Clean Architecture, and Jetpack Compose.
🔊 Built real-time translation & speech systems at WeHear, integrating cloud services (GCP Translation, Speech Recognition) and offline models.
🤖 Exploring Android × AI — currently conceptualizing Pill Pocket, an AI-powered medication assistant.
| Platform | Link |
|---|---|
| 🌐 GitHub | https://github.com/AvikMakwana |
| https://www.linkedin.com/in/avikmakwana/ |
Apache License 2.0
Copyright 2025⭐ If you like this library, please give it a star on GitHub!
Your support motivates further development.