Public class networkcheck {/*** network availability */public static Boolean isnetworkavailable (context) {connectivitymanager connectivity = (connectivitymanager) context. getsystemservice (context. connectivity_service); If (connectivity = NULL) {} else {networkinfo [] info = connectivity. getallnetworkinfo (); If (info! = NULL) {for (INT I = 0; I <info. length; I ++) {If (info [I]. getstate () = networkinfo. state. connected) {return true ;}}} return false;}/*** whether WiFi is enabled */public static Boolean iswifienabled (context) {connectivitymanager mgrconn = (connectivitymanager) context. getsystemservice (context. connectivity_service); telephonymanager mgrtel = (telephonymanager) context. getsystemservice (cont Ext. telephony_service); Return (mgrconn. getactivenetworkinfo ()! = NULL & mgrconn. getactivenetworkinfo (). getstate () = networkinfo. state. connected) | mgrtel. getnetworktype () = telephonymanager. network_type_umts);}/*** determines whether the current network is a Wi-Fi network * If (activenetinfo. getType () = connectivitymanager. type_mobile) {// determine the 3G network ** @ Param context * @ return Boolean */public static Boolean iswifi (context) {connectivitymanager = (connectivitymanager) Context. getsystemservice (context. connectivity_service); networkinfo activenetinfo = connectivitymanager. getactivenetworkinfo (); If (activenetinfo! = NULL & activenetinfo. getType () = connectivitymanager. type_wifi) {return true;} return false;}/*** determine whether the current network is a 3G network ** @ Param context * @ return Boolean */public static Boolean is3g (context) {connectivitymanager = (connectivitymanager) context. getsystemservice (context. connectivity_service); networkinfo activenetinfo = connectivitymanager. getactivenetworkinfo (); I F (activenetinfo! = NULL & activenetinfo. GetType () = connectivitymanager. type_mobile) {return true ;} return false ;}}