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.
So, regarding the above - should I write a manual http request in order to ensure or there's another way ?
Here's some code I'm using
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected() && cm.getActiveNetworkInfo().isAvailable();