admin 管理员组

文章数量: 887042

测试网络是否连接的是wifi且wifi是否能上网

public static boolean isWifiActive(Context cxt){

Context context = cxt.getApplicationContext();

ConnectivityManager connectivity = (ConnectivityManager )context.getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo[] info;

if(connectivity != null){

info = connectivity.getAllNetworkInfo();

if(info != null){

for(int i = 0; i < info.length; i++){

if(info[i].getTypeName().equals("WIFI") && info[i].isConnected()){

return true;

}

}

}

}

}

本文标签: 是否能 WiFi