I’m looking for best technique to verify internet over WiFi or Cell. Let’s say you are connected to some AP but you don’t now if internet exists.
Today I have 2 options by using HttpURLConnection:
- Download file from cdn server
- to send request to trust web page like google.com and get response 200.
Any other ways?
All suggestions would be appreciated.
On some level, ‘ability to access internet endpoints’ is equivalent to ‘having internet access’. You could consider some algorithm:
which will conclusively establish connectivity. In other words, being able to connect to any one site is sufficient positive proof, but theoretically you would need to enumerate every site to prove non-connectivity. In practice, checking a few major sites is obviously sufficient. Otherwise (without some sort of meta-information about networks, ISPs, etc; which is unavailable) there’s no way to conclusively demonstrate “internet” connectivity other than… connecting to the internet.
Of course as you comment, checking various internet-based applications can’t hurt either; it’s just a different form of an equivalent technique.