Check real internet connection
<p>In my application I need to check whether device is connected to Internet. I tried using ConnectivityManager but it doesn't give a 100% precise result. For instance, I might have a wi-fi connection but still don't have access to internet resources. In my case I've got to open a VPN connection, after I've connected to via wi-fi, in order to get real access to Internet. So the approach with ConnectivityManager doesn't work.</p>

<p>So, regarding the above - should I write a manual http request in order to ensure or there's another way ?</p>

<p>Here's some code I'm using</p>

<pre><code>ConnectivityManager cm =  (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getActiveNetworkInfo() != null &amp;&amp; cm.getActiveNetworkInfo().isConnected() &amp;&amp; cm.getActiveNetworkInfo().isAvailable();
</code></pre>
