本文介绍了如何在Android中对服务器执行ping操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何ping通Android中的某些Web服务器以测试是否已连接互联网?因此,我需要对指定的站点执行ping操作,如果没有互联网,则返回false;如果有,则返回true.
How can I ping some web server in Android to test if I've Internet connection?So I need the method which pings the given site and returns false if I've no Internet and true if I have.
推荐答案
请参见此方法,这是检查与给定服务器的连接的最佳方法:
See this method, it's the best way to check for connectivity to a given server:
http://developer.android.com/reference/java/net/InetAddress.html#isReachable(int)
这篇关于如何在Android中对服务器执行ping操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!