How to check if wifi is connected in android

If you want to try downloading something unless you have wifi. You can use the following code snippet to be able to check if wifi is enabled.

You will be able to use the ConnectivityManager to get the state of the Wifi adapter. From there you canĀ check if it is connected or even available.

Note: Add

to your AndroidManifest.xml for this to work.