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

I don’t want my user to even try downloading something unless they have Wi-Fi connected. However, I can only seem to be able to tell if Wi-Fi is enabled, but they could still have a 3G connection. android.net.wifi.WifiManager m = (WifiManager) getSystemService(WIFI_SERVICE); android.net.wifi.SupplicantState s = m.getConnectionInfo().getSupplicantState(); NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(s); if (state != NetworkInfo.DetailedState.CONNECTED) { … Read more

Broadcast receiver for checking internet connection in android app

I am developing an android broadcast receiver for checking internet connection. The problem is that my broadcast receiver is being called two times. I want it to get called only when the network is available. If it is unavailable, I don’t want notified. This is the broadcast receiver public class NetworkChangeReceiver extends BroadcastReceiver { @Override … Read more