Wi-Fi connection
Android settings
smartphone tips
Android guide
network troubleshooting

How do I see if Wi-Fi is connected on Android?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

On Android, checking whether Wi-Fi is connected depends on whether you are asking from the user interface or from app code. In application code, the modern answer is to use ConnectivityManager and inspect NetworkCapabilities rather than the older deprecated NetworkInfo APIs. That distinction matters because a user-facing settings answer and an application-level connectivity answer solve different problems and expose different signals.

Use ConnectivityManager on Modern Android

The current pattern is:

  • get the active network
  • get its capabilities
  • check whether it uses TRANSPORT_WIFI

Here is a Kotlin example:

kotlin
1import android.content.Context
2import android.net.ConnectivityManager
3import android.net.NetworkCapabilities
4
5fun isWifiConnected(context: Context): Boolean {
6    val connectivityManager =
7        context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
8
9    val network = connectivityManager.activeNetwork ?: return false
10    val capabilities = connectivityManager.getNetworkCapabilities(network) ?: return false
11
12    return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
13}

If this returns true, the active network connection is currently using Wi-Fi.

Your app also needs the ACCESS_NETWORK_STATE permission:

xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Distinguish Wi-Fi Enabled from Wi-Fi Connected

These are not the same thing:

  • Wi-Fi enabled means the radio is on
  • Wi-Fi connected means the active network is currently Wi-Fi

A device can have Wi-Fi turned on but still be using mobile data because it is not associated with an access point or because the Wi-Fi network has no usable internet path.

That is why checking transport on the active network is usually more useful than only checking whether Wi-Fi hardware is enabled.

Do Not Use Deprecated NetworkInfo for New Code

Older examples often look like this:

kotlin
val info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
val connected = info?.isConnected == true

That style is deprecated and should not be the default for new Android code. It may still appear in older codebases, but modern apps should prefer activeNetwork plus NetworkCapabilities.

If You Need to React to Changes

If the app needs to respond when connectivity changes, register a network callback instead of polling repeatedly:

kotlin
1import android.net.ConnectivityManager
2import android.net.Network
3import android.net.NetworkCapabilities
4import android.net.NetworkRequest
5
6fun registerWifiCallback(connectivityManager: ConnectivityManager) {
7    val request = NetworkRequest.Builder().build()
8
9    connectivityManager.registerNetworkCallback(
10        request,
11        object : ConnectivityManager.NetworkCallback() {
12            override fun onCapabilitiesChanged(network: Network, capabilities: NetworkCapabilities) {
13                val onWifi = capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
14                println("on Wi-Fi: $onWifi")
15            }
16        }
17    )
18}

That approach is better when the UI or data layer needs to adapt live to network changes.

If You Mean as a User, Not as a Developer

If the question is about checking Wi-Fi manually on the device, Android already shows that in Quick Settings and system settings. But from an application-development perspective, the network-capabilities API is the correct programmatic answer.

Keep those two contexts separate. Device settings and app logic are solving different problems.

Common Pitfalls

The biggest mistake is treating “Wi-Fi turned on” as equivalent to “Wi-Fi connected and active.” Those are different states.

Another issue is relying on deprecated NetworkInfo examples from older Android tutorials. They still circulate widely, but they are not the preferred modern API.

Developers also sometimes forget the ACCESS_NETWORK_STATE permission and then wonder why connectivity checks fail or return incomplete data.

Finally, do not assume Wi-Fi implies actual internet reachability. A Wi-Fi transport can exist even when the network is captive, broken, or blocked upstream.

Summary

  • In app code, use ConnectivityManager with NetworkCapabilities to detect active Wi-Fi transport.
  • Add the ACCESS_NETWORK_STATE permission.
  • Distinguish Wi-Fi enabled from Wi-Fi actually connected and active.
  • Avoid deprecated NetworkInfo for new Android code.
  • Use a network callback if the app needs to react to connectivity changes over time.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.