I am using the following code to check internet connectivity:
try {
                        HttpURLConnection httpConnection = (HttpURLConnection) (new URL("http://clients3.google.com/generate_204").openConnection());
                        httpConnection.setRequestProperty("User-Agent", "Test");
                        httpConnection.setRequestProperty("Connection", "close");
                        httpConnection.setConnectTimeout(15000); 
                        httpConnection.connect();
                        if (httpConnection.getResponseCode() == 204 && httpConnection.getContentLength() == 0){
                        //internet is avialable
                            return;
                        }else{
                             Log.e(TAG, "Internet connection error: " + httpConnection.getResponseCode()
                                     + ": " + httpConnection.getResponseMessage());
                        }
                    } catch (IOException e) {
                        Log.e(TAG, "Internet connection error: " + e);
                    }
And i am getting the following response : code: 204 message: No Content
but content length is greater than 0 and hence it fails. Could some one please help me understand what is going on?
Thanks, Sunny
 
     
     
    