Android check internet connection when 3g is available but not accessible -


i've been looking on other questions, can not find something, while in review activity need internet connection, activated 3g can not connect (have exceeded data use or firewall) tutorials or have found not include that.

i use little function detect public wifi redirects sign on page. if function returns false, means not connect intended page despite having 3g or wifi on. can show user page, example "no internet connection" page.

public boolean networksignon() {     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.v("walled garden check - not portal: exception " + e, "");         return false;     } {         if (urlconnection != null) urlconnection.disconnect();     } } 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -