asksven / BetterWifiOnOff

An intelligent agent to manage your Wifi status
26 stars 14 forks source link

[feature] implement alternate more precise cage check #115

Closed asksven closed 11 years ago

asksven commented 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(); } }

chrone81 commented 11 years ago

+1. Is enabling this improve battery life? And what is the checking time interval?