简体   繁体   English

Android Wi-Fi:“不支持地址族”

[英]Android Wi-Fi: 'Address family not supported'

I am making an application which makes use of the internet. 我正在制作一个利用互联网的应用程序。

It works fine when the Wi-Fi is availble. Wi-Fi可用时,它可以正常工作。 But when the Wi-Fi is turned off, it gives me an error: "Address family not supported". 但是,当Wi-Fi关闭时,它给我一个错误:“不支持地址族”。

I am using the NetworkInfo Class to know, if the network is available. 我正在使用NetworkInfo类来知道网络是否可用。 Im using WifiManager to enable and manage Wi-fi connection if available. 我使用WifiManager启用和管理Wi-Fi连接(如果可用)。

I've been using the following code to check if a network is available: 我一直在使用以下代码检查网络是否可用:

ConnectivityManager mConnectivity = (ConnectivityManager) this
                                        .getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = mConnectivity.getActiveNetworkInfo();
if (info == null) {
    // No inet
}

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

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