The following tool classes are mainly used for:
(1) Check if there is a network,
(2) Check if there is WiFi,
(3) Check if there is a mobile network
ImportAndroid.content.Context;ImportAndroid.net.ConnectivityManager;ImportAndroid.net.NetworkInfo; Public class commonutils { /** Check if there is a network * / Public Static Boolean isnetworkavailable(Context context) {Networkinfo info = getnetworkinfo (context);if(Info! =NULL) {returnInfo.isavailable (); }return false; }/** Check if it is WiFi * / Public Static Boolean Iswifi(Context context) {Networkinfo info = getnetworkinfo (context);if(Info! =NULL) {if(Info.gettype () = = Connectivitymanager.type_wifi)return true; }return false; }/** Check if it is a mobile network * / Public Static Boolean IsMobile(Context context) {Networkinfo info = getnetworkinfo (context);if(Info! =NULL) {if(Info.gettype () = = Connectivitymanager.type_mobile)return true; }return false; }Private StaticNetworkinfoGetnetworkinfo(Context context) {Connectivitymanager cm = (connectivitymanager) context. Getsystemservice (Context.connectivity_serv ICE);returnCm.getactivenetworkinfo (); }/** Check if the SD card is present * / Public Static Boolean Checksdcard() {if(Android.os.Environment.getExternalStorageState (). Equals (Android.os.Environment.MEDIA_MOUNTED))return true;Else return false; }}
Android Tools sorting (1) Check if there is a network, check if the SD card exists