Closed asksven closed 11 years ago
private boolean isConnected() { HttpURLConnection urlConnection = null; try { URL url = new URL("http://clients3.google.com/generate_204"); urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setInstanceFollowRedirects(false); urlConnection.setConnectTimeout(10000); urlConnection.setReadTimeout(10000); urlConnection.setUseCaches(false); urlConnection.getInputStream(); return urlConnection.getResponseCode() == 204; } catch (IOException e) { log("Walled garden check - probably not a portal: exception " + e); return false; } finally { if (urlConnection != null) urlConnection.disconnect(); } }
+1. Is enabling this improve battery life? And what is the checking time interval?
private boolean isConnected() { HttpURLConnection urlConnection = null; try { URL url = new URL("http://clients3.google.com/generate_204"); urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setInstanceFollowRedirects(false); urlConnection.setConnectTimeout(10000); urlConnection.setReadTimeout(10000); urlConnection.setUseCaches(false); urlConnection.getInputStream(); return urlConnection.getResponseCode() == 204; } catch (IOException e) { log("Walled garden check - probably not a portal: exception " + e); return false; } finally { if (urlConnection != null) urlConnection.disconnect(); } }