简体   繁体   English

检查设备是否连接到特定网络

[英]Checking if device is connected to certain network

How can I check if my Android application is able to connect to a certain host? 如何检查我的Android应用程序是否能够连接到特定主机? For example, I can make a HTTP GET call from a company web service if I am connected to the company network. 例如,如果我连接到公司网络,则可以从公司Web服务进行HTTP GET调用。 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". 如果我不在公司网络(路由器等)上,则无法进行HTTP GET调用,并且显示“无法解析主机:没有与主机名关联的地址”。 How do I check if the wifi or data is within the company? 如何检查wifi或数据是否在公司内部?

That error means you don't have an IP related to the domain you want to surf. 该错误意味着您没有与要浏览的域相关的IP。 There is something wrong with DNS. DNS出现问题。

Try to use nslookup to check your connection with host you want to visit and then check if HTTP GET returns error. 尝试使用nslookup检查与您要访问的主机的连接,然后检查HTTP GET是否返回错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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