简体   繁体   中英

Checking if device is connected to certain network

How can I check if my Android application is able to connect to a certain host? For example, I can make a HTTP GET call from a company web service if I am connected to the company network. If I am not on the company network (router, etc.) I can't make the HTTP GET call and it says "Unable to resolve host : No address associated with hostname". How do I check if the wifi or data is within the company?

That error means you don't have an IP related to the domain you want to surf. There is something wrong with DNS.

Try to use nslookup to check your connection with host you want to visit and then check if HTTP GET returns error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM