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.
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:
If this returns true, the active network connection is currently using Wi-Fi.
Your app also needs the ACCESS_NETWORK_STATE permission:
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:
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:
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
ConnectivityManagerwithNetworkCapabilitiesto detect active Wi-Fi transport. - Add the
ACCESS_NETWORK_STATEpermission. - Distinguish Wi-Fi enabled from Wi-Fi actually connected and active.
- Avoid deprecated
NetworkInfofor new Android code. - Use a network callback if the app needs to react to connectivity changes over time.
Related reading
- How do I see which version of Swift I'm using?
- How do I "select Android SDK" in Android Studio?
- How do I select Android SDK in Android Studio?
- How do I set a weight to SF Symbols for iOS 13?
- How do I set a number of retry attempts in RabbitMQ?
- How do I set a number of retry attempts in RabbitMQ?
- How do I set a weight to SF Symbols for iOS 13?
- How do I Set Background image in Flutter?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.