title: Problem: Android's isConnected() used to get current state of WiFi often returns false even when the device is connected
body: <p>My Android app can only function with WiFi connected to the Internet. Thus, I use the following code to check if the device is connected:</p>
  
  <pre><code>ConnectivityManager conMgr = (ConnectivityManager)getSystemService(Activity.CONNECTIVITY_SERVICE);
  boolean wifi = conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
  </code></pre>
  
  <p>However, very often when the application is launched and WiFi connected to the Internet, I get the notification that is only shown when <code>wifi = false</code>. Have I missed something, or the check is not that accurate?</p>