Android:检查与服务器的连接
所以我有一种方法可以检查设备是否连接到互联网基于此
它工作正常,但在某些情况下,我发现虽然手机显示已连接到互联网,但它仍然无法访问我的服务器。我真正想做的是检查与我的特定 URL 的连接。
我该如何实现呢?
So I have a method that checks if the device is connected to the internet based on this one
It works ok, but in a couple of cases I find that although the phone shows being connected to the internet, it still does not have access to my server. What I am really looking to do it check connection to my specific URL.
How could I implement that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以执行以下操作:
这将尝试连接到您的服务器的 URL,如果失败,则显然您没有连接。 ;-)
You could do something like:
This will attempt to connect to your server's URL and if it fails, you obviously don't have a connection. ;-)
你可以尝试
You can try