I followed this http://www.helloandroid.com/tutorials/it-internet-connection-checker-snippet to check if there is internet connection on my android device.
The code block looks like this
URL url = new URL("http://www.google.com");
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
urlc.setConnectTimeout(1000 * 5); // Timeout is in seconds
urlc.connect();
if (urlc.getResponseCode() == 200) {
// http response is OK
Log.d("db", "Connection to " + url.toString() + " successful!");
return true;
}
However, my device is connected to open Wifi points which requires webpage log in before accessing the internet. This code seems to return true even without log in.
Was wondering what I can do?