title: How to check that android phone is not connected to internet?
body: <p>I'm developing an application in android which fetches data from the database. I have developed the code to find whether the WIFI or Mobile data is ON or OFF like this:</p>
  
  <pre><code>protected boolean isNetworkAvailable()
  {
      boolean connection=true;
      ConnectivityManager connectivityManager=(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
      NetworkInfo[] activeNetworkInfo=connectivityManager.getAllNetworkInfo();
      for(NetworkInfo ni:activeNetworkInfo)
      {
          if(ni.getTypeName().equalsIgnoreCase("WIFI"))
              if(ni.isConnected())    
                  haveConnectedWifi=true;
          if(ni.getTypeName().equalsIgnoreCase("MOBILE"))
              if(ni.isConnected())
                  haveConnectedMobile=true;
  
      }
      if(haveConnectedWifi==false &amp;&amp; haveConnectedMobile==false)
      {
  
      connection=false;
      }
          return connection;
  
      }
  </code></pre>
  
  <p>Now suppose that my WIFI or Mobile Data network is ON but I'm not connected to internet at all(WIFI not connected to any access point).How can i show this in android?</p>
  
  <p>Thanks,</p>