的我有一个测试,如果WiFi连接可用代码。Wifi连接工作inspite接入点
public boolean checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnected()) {
try {
URL url = new URL("http://www.google.com");
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
urlc.setRequestProperty("User-Agent", "Test");
urlc.setRequestProperty("Connection", "close");
urlc.setConnectTimeout(3000);
urlc.setReadTimeout(4000);
urlc.connect();
if (urlc.getResponseCode() == HttpURLConnection.HTTP_OK) {
Log.i(TAG,"Internet connection is OK");
return true;
}
} catch (MalformedURLException mue) {
mue.printStackTrace();
} catch (IOException ie) {
ie.printStackTrace();
}
}
Log.i(TAG, "No internet connection.");
return false;
}
访问互联网,我必须通过接入点,这就是为什么我espacially平谷歌,因为我需要的,如果我们也是。我已经注意到登录,在许多情况下,沉绵我不记录进入强制门户,代码窗口达到谷歌并返回true。我也能够上网服务器,比如ftp。 有谁知道这种行为的原因是什么?有没有其他人注意到这种行为?
谢谢
我没有看到你ping通谷歌。也不是登录。也不是一个俘虏门户。无论如何。 – greenapps