android - Establishing if a device is connected to a particular site -


i trying establish if device has connection particular site. if should start intent, if doesn't should throw toast.

it seems throw toast though if device can see site:-

public void gotostation(view v) {      try {         inetaddress ina = inetaddress.getbyname("http://www.lisbury.co.uk");          ina.isreachable(10000); {                    intent myintent = new intent(mainactivity.this, customizedlistviewstation.class);                   startactivityforresult(myintent, 0);          }      } catch (ioexception ioe) {         toast.maketext(this, "you need data connection view safety zones", toast.length_long).show();      }       } 

 inetaddress ina = inetaddress.getbyname("www.lisbury.co.uk"); 

but isreachable doesn't guarantee device can connect site - isreachable using icmp echo , tcp port 7, both can filtered out, yet host available, , vice versa - host can available, web server down


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -