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
Post a Comment