title: Detect whether there is an Internet connection available on Android
body: <blockquote>
  <p><strong>Possible Duplicate:</strong><br />
  <a href="https://stackoverflow.com/questions/1560788/how-to-check-internet-access-on-android-inetaddress-never-timeouts">How to check internet access on Android? InetAddress never timeouts</a></p>
  </blockquote>
  
  <p>I need to detect whether the Android device is connected to the Internet.</p>
  <p>The <code>NetworkInfo</code> class provides a non-static method <code>isAvailable()</code> that sounds perfect.</p>
  <p>Problem is that:</p>
  <pre><code>NetworkInfo ni = new NetworkInfo();
  if (!ni.isAvailable()) {
      // do something
  }
  </code></pre>
  <p>throws this error:</p>
  <pre class="lang-none prettyprint-override"><code>The constructor NetworkInfo is not visible.
  </code></pre>
  <p>Safe bet is there is another class that returns a <code>NetworkInfo</code> object. But I don't know which.</p>
  <ol>
  <li>How to get the above snippet of code to work?</li>
  <li>How could I have found myself the information I needed in the online documentation?</li>
  <li>Can you suggest a better way for this type of detection?</li>
  </ol>