<span style= "FONT-SIZE:18PX;" >//whether to connect Wifipublic static Boolean iswificonnected (context context) {Connectivitymanager Connectivitymanager = ( Connectivitymanager) Context.getsystemservice (Context.connectivity_service); Networkinfo wifinetworkinfo = Connectivitymanager.getnetworkinfo (Connectivitymanager.type_wifi); Wifinetworkinfo.isconnected ()) {return true;} return false;} /** * To determine the network connection status * * @return true, available; false, */public static Boolean isopennetwork (Context ctx) {Connectivityman Ager Connmanager = (Connectivitymanager) ctx.getsystemservice (Context.connectivity_service); Connmanager.getactivenetworkinfo ()! = null) {return Connmanager.getactivenetworkinfo (). isavailable ();} return false;} </span>
Android determines whether WiFi is connected and the status of the network is judged