title: How to check Wifi is connected, but no Internet access in Android
body: <p>I would like to know why wifi is connected but there is no internet access in Android. How can i check it?
  My code is:</p>
  
  <pre><code>ConnectivityManager cn=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo nf=cn.getActiveNetworkInfo();
  
   if(nf != null &amp;&amp; nf.isConnected() )
           {
              Flag2=false;
              Log.e("network--------", "1--------------");
  
              if (cn.getActiveNetworkInfo().isConnectedOrConnecting())
              {Log.e("network--------", "11111111111111--------------");
               }
              else
              {Log.e("network--------", "2222222222222--------------");
              }
          }
  
   else 
           {
              Log.e("network--------", "2--------------");
   }
  </code></pre>