Questions tagged «android-internet»

14
检测Android设备是否具有Internet连接
我需要告诉我的设备是否可以连接互联网。我找到了许多答案,例如: private boolean isNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null; } (摘自“ 检测到Android上是否存在Internet连接”。) 但这是不对的,例如,如果我连接到无法访问Internet的无线网络,则此方法将返回true… 是否有办法判断设备是否具有Internet连接,而不是仅连接设备到什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.